Visual Basic - ayuda con código en acces

Life is soft - evento anual de software empresarial
 
Vista:

ayuda con código en acces

Publicado por Manuel (17 intervenciones) el 09/09/2006 12:28:39
Hola a todos, soy novato y quiero hacer un programa para meter datos en una base de datos Access y hacerlo desde un textbox pero no tengo ni idea de como conectar y manipular la base a través de Visual Basic. Agradecería si alguien puede mandarme un código " comentado" para aprender, de como introducir, buscar y eliminar datos de la base de datos desde el texbox y que fuese muy muy fácil de entender.Muchas gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:ayuda con código en acces

Publicado por csdk (127 intervenciones) el 22/09/2006 23:11:41
Public RST_EMPLEADO As New Recordset
Public RST_NIVEL As New Recordset
Public ADOCONN As New ADODB.Connection 'CONEXION*************
Public Function conex()
On Error Resume Next
ADOCONN.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source=" + App.Path + "\VAL.mdb"
ADOCONN.Open

If Err.Number Then

MsgBox "Se ha producido el siguiente error:" & vbCrLf & _
Err.Number & ", " & Err.Description
End
End If
End Function
Public Function desconectar()
ADOCONN.Close
End Function

'entradad de registros desde text
Call conex
RST_EMPLEADO.Source = "INSERT INTO TB_CON VALUES('" & TXT_NOM.Text & "','" & TXT_NACIO.Text & "','" & TXT_EDAD.Text & "','" & TXT_EDOCIVIL.Text & "','" & TXT_DOMI.Text & "','" & TXT_PUESTO.Text & "'," & TXT_SALARIO.Text & "," & TXT_POR.Text & "," & TXT_VAC.Text & "," & TXT_ASIG.Text & ",'" & Combo1.Text & "','" & Combo2.Text & "' ,'" & DTPicker1.Value & "','" & TXT_GT.Text & "','" & Combo3.Text & "' , '" & Combo4.Text & "'," & TXT_CVL_EMP.Text & ")"
RST_EMPLEADO.ActiveConnection = ADOCONN
MsgBox "REGISTRO ALMACENADO", vbInformation
RST_EMPLEADO.Open
desconectar
'actualizacion
conex
RST_NIVEL.Source = "Update tb_CON set nombre_COMPLETO = '" & Txt_Nombre.Text & "',s_diario =" & cosa2 & ", curp ='" & Txt_Curp.Text & "',RFC='" & Txt_Rfc.Text & "',cvl_nivel=" & CVL_N & ",cvl_seccion=" & CVL_S & ",puesto='" & Cbo_Puesto.Text & "',tS=" & cosa & " WHERE cvl_empleado ='" & txt_AcEm.Text & "'"
RST_NIVEL.ActiveConnection = ADOCONN
RST_NIVEL.Open
MsgBox ("El registro se a modificado"), vbInformation
desconectar
'eliminacion
conex
RST_EMPLEADO.Source = "delete from tb_CON where cvl_emp=(" & TXT_CVL_EMP.Text & ")"
RST_EMPLEADO.ActiveConnection = ADOCONN
RST_EMPLEADO.Open
desconectar
MsgBox ("el registro se a eliminado"), vbCritical, "REGISTRO ELIMINADO"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar