Professional Documents
Culture Documents
com
2. Abrir ACCESS y crear una base de datos con el nombre colegio, en la carpeta data del directorio que hemos creado
TIPO DE DATOS
DESCRIPCIN
FORMATO
Pgina 1
al_apel
Texto
50
al_nomb
Texto
50
al_sexo
Texto
Sexo
al_fena
Fecha/Hora
Fecha de nacimiento
Fecha corta
al_dire
Texto
Direccin
150
al_tele
Texto
Telfono
al_coel
Texto
Correo electrnico
45
4. Ahora cierra Access porque vamos a Cifrar con contrasea la base de datos que hemos creado, para restringir el acceso a la misma; para ello seguimos los pasos:
4.1.Abrir Access 4.2.Seleccionamos Archivo/Abrir 4.3.Ubicamos la base de datos, la seleccionamos y en el botn Abrir elegimos Abrir en modo exclusivo 4.4.Ahora vamos a Archivo/Cifrar con contrasea
4.5.Escribimos la contrasea y luego la confirmamos (mi contrasea es ptgmoa); finalmente hacemos clic en el botn ACEPTAR
4.6.Si sale algn otro mensaje solo das clic en ACEPTAR Ya est la base de datos est protegida por contrasea Cierra Access
Visual Basic .Net 2010 con Access 2010 ecastaneda@incux.com creas nuevo con el nombre colegio y diseamos un
Basic
.Net,
el
Proyecto formulario:
6.
PROPIEDAD frmAlumno
VALOR
Pgina 3
ControlBox Label1 Label2 Label3 Label4 Label5 Label6 Label7 Label8 TextBox1 Text Text Text Text Text Text Text Text Name MaxLength
False Cdigo Apellidos Nombres Sexo Fecha de nacimiento Direccin Telfono Correo txtCod 7
TextBox2
Name MaxLength
txtApe 50
TextBox3
Name MaxLength
txtNom 50
TextBox4
Name MaxLength
txtSex 1
DateTimePicker1
Name Format
dtpFec Short
TextBox5
Name MaxLength
txtDir 150
TextBox6
Name MaxLength
txtTel 6
TextBox7
Name MaxLength
txtCor 45
Button1
Name Text
btnNue NUEVO
Button2
Name Text
btnEdi EDITAR
Button4
Name Text
btnSal SALIR
Button5
Name Text
btnPri <<
Button6
Name Text
btnAnt <
Button7
Name
btnSig >
Text
>> btnUlt
b t n U lt
Imports Public
Dim strConexion As String = "Provider=Microsoft.ACE.OLEDB.12.0; DATA SOURCE = D:\colegio\data\colegio.accdb; Jet OLEDB:Database Password=ptgmoa;"
Dim
DS
As
New
DataSet
Dim CB As OleDbCommandBuilder Dim Posicion As Integer Private Sub BloquearBotones() = = = = = = False False False False False False
Private
Private Sub frmAlumno_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try
Binding("Text", Binding("Text",
DS, DS,
"alumno.al_apel"))
txtNom.DataBindings.Add(New "alumno.al_nomb")) txtSex.DataBindings.Add(New "alumno.al_sexo")) dtpFec.DataBindings.Add(New "alumno.al_fena")) txtDir.DataBindings.Add(New "alumno.al_dire")) txtTel.DataBindings.Add(New "alumno.al_tele")) txtCor.DataBindings.Add(New "alumno.al_coel"))
If btnNue.Text = "NUEVO" Then Me.BindingContext(DS, "alumno").AddNew() txtCod.Focus() btnNue.Text = "GUARDAR" btnEdi.Text = "CANCELAR" BloquearBotones() Else Try BindingContext(DS, "alumno").EndCurrentEdit() DA.Update(DS, "alumno") DS.Tables("alumno").AcceptChanges() btnNue.Text = "NUEVO" btnEdi.Text = "EDITAR" DesbloquearBotones() Catch ex As Exception MsgBox(ex.Message)
Pgina 7
End Try End If End Sub Private Sub btnEdi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdi.Click If btnEdi.Text = "EDITAR" Then If txtCod.Text = "" Then MsgBox("No existen registros MsgBoxStyle.Critical,"Error") Else btnNue.Text = "GUARDAR" btnEdi.Text = "CANCELAR" BloquearBotones() End If Else BindingContext(DS, "alumno").CancelCurrentEdit() btnNue.Text = "NUEVO" btnEdi.Text = "EDITAR" DesbloquearBotones() End If End Sub Private Sub btnBor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBor.Click If txtCod.Text = "" Then eliminar", para editar",
If MsgBox("Est seguro que desea eliminar el registro?", MsgBoxStyle.YesNo, "Eliminar") = MsgBoxResult.Yes Then
Private Sub btnPri_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPri.Click Me.BindingContext(DS, "alumno").Position = 0 End Sub
Private Sub btnAnt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnt.Click Me.BindingContext(DS, "alumno").Position -= 1 End Sub
Private Sub btnSig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSig.Click Me.BindingContext(DS, "alumno").Position += 1 End Sub Private Sub btnUlt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUlt.Click Me.BindingContext(DS, "alumno").Position = BindingContext(DS, "alumno").Count End Sub End Class
9.
Pgina 9
Pgina 11