Visual Basic - Necesito su ayuda....

Life is soft - evento anual de software empresarial
 
Vista:

Necesito su ayuda....

Publicado por bekyna (31 intervenciones) el 07/03/2006 19:48:48
Alguien que me pueda proporcionar un ejemplo, para guardar datos a una base de datos de Access, se los voy agradecer mucho tengo problemas con ello y creo que es porque se pare mi código que tiene muchas consultas, pongo un pequeño ejemplo:

Private Sub INGRESO()
Dim VLB1 As String
Dim VLB3 As String

Dim DIR As String
Dim CSQL As String
Dim CCSQL As String
Dim CN As ADODB.Connection

If MsgBox("Deseas guardar", vbQuestion + vbDefaultButton1 + vbYesNo) = vbYes Then

On Error GoTo com_error

If Form5.Combo3.Text = "VERIFICACION CERO-SPAN" Then
Form5.Adodc1.Recordset.Update
Form5.Adodc2.Recordset.Update
End If


DIR = "\Database\RAUT.MDB"


'parte pequeña NO 1er
If (MaskEdBox2.Text <> "" And Text26.Text <> "" And Text105.Text <> "" And Text127.Text <> "") Then
'CUANDO ESTAN LLENOS POR COMPLETO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1
VLB3 = "INSERT INTO verificacion_LB(Clave_de_Control,Fecha_Actividad, ClavOp, Clavpar, ClavEstacion, No_Serie_Modelo_Analizador, UltimafechadeCa_Ana, No_Serie_Modelo_Calibrador, Fecha_Cal, No_serie_AireCero, Fecha_Mant, clavAct,Ana_LB_Ant,Ana_LB_Des,Cambiofiltro, Observaciones,PMT_LBAnt, PMT_LBDes,Fecha_Instalo_Equipo, Fecha_Retiro_Equipo)VALUES('" & Text1.Text _
& " ', '" & MaskEdBox2.Text & "','" & Combo2.Text & "','" & Label15.Caption & "','" & Combo1.Text & "','" & Combo7.Text & "','" & MaskEdBox3.Text & "','" & Combo8.Text & "','" & MaskEdBox4.Text & "','" & Combo5.Text & "','" & MaskEdBox5.Text & "','" & Label70.Caption & "','" & Text24.Text & "','" & Text26.Text & "','" & Combo9.Text & "','" & Text29.Text & "','" & Text60.Text & "','" & Text61.Text & "','" & Text105.Text & "','" & Text127.Text & "')"
' 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Set CN = New ADODB.Connection
CN.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & App.Path & DIR & ";" & _
"JET OLEDB:DATABASE PASSWORD=INSIDE"
CN.Execute (VLB3)
CN.Close


ElseIf (MaskEdBox2.Text <> "" And Text26.Text <> "" And Text105.Text = "" And Text127.Text = "") Then
'CUANDO ESTAN LLENOS POR COMPLETO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1
VLB3 = "INSERT INTO verificacion_LB(Clave_de_Control,Fecha_Actividad, ClavOp, Clavpar, ClavEstacion, No_Serie_Modelo_Analizador, UltimafechadeCa_Ana, No_Serie_Modelo_Calibrador, Fecha_Cal, No_serie_AireCero, Fecha_Mant, clavAct, Ana_LB_Ant,Ana_LB_Des,Cambiofiltro, Observaciones,PMT_LBAnt, PMT_LBDes)VALUES('" & Text1.Text _
& " ', '" & MaskEdBox2.Text & "','" & Combo2.Text & "','" & Label15.Caption & "','" & Combo1.Text & "','" & Combo7.Text & "','" & MaskEdBox3.Text & "','" & Combo8.Text & "','" & MaskEdBox4.Text & "','" & Combo5.Text & "','" & MaskEdBox5.Text & "','" & Label70.Caption & "','" & Text24.Text & "','" & Text26.Text & "','" & Combo9.Text & "','" & Text29.Text & "','" & Text60.Text & "','" & Text61.Text & "')"
' 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Set CN = New ADODB.Connection
CN.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & App.Path & DIR & ";" & _
"JET OLEDB:DATABASE PASSWORD=INSIDE"
CN.Execute (VLB3)
CN.Close

...
END SUB

Private Sub CONTINUACION_INGRESO()
Dim VLB1 As String
Dim VLB2 As String
Dim CSQL As String
Dim CCSQL As String
Dim CN As ADODB.Connection
Dim DIR As String
DIR = "\Database\RAUT.MDB"

'NO 1ra parte
If (Form5.Combo3.Text = "2 VERIF. DE LINEAS BASES" And Text5.Text <> "" And Text105.Text <> "" And Text127.Text <> "") Then
'CUANDO ESTAN LLENOS POR COMPLETO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1
VLB1 = "INSERT INTO verificacion_LB(Clave_de_Control,Fecha_Actividad, ClavOp, Clavpar, ClavEstacion, No_Serie_Modelo_Analizador, UltimafechadeCa_Ana, No_Serie_Modelo_Calibrador, Fecha_Cal, No_serie_AireCero, Fecha_Mant, clavAct, Ana_LB_Ant,Ana_LB_Des,Cambiofiltro, Observaciones,PMT_LBAnt, PMT_LBDes,Fecha_Instalo_Equipo, Fecha_Retiro_Equipo)VALUES('" & Text1.Text _
& " ', '" & MaskEdBox1.Text & "','" & Combo2.Text & "','" & Label15.Caption & "','" & Combo1.Text & "','" & Combo7.Text & "','" & MaskEdBox3.Text & "','" & Combo8.Text & "','" & MaskEdBox4.Text & "','" & Combo5.Text & "','" & MaskEdBox5.Text & "','" & Combo3.Text & "','" & Text3.Text & "','" & Text5.Text & "','" & Combo4.Text & "','" & Text28.Text & "','" & Text58.Text & "','" & Text59.Text & "','" & Text105.Text & "','" & Text127.Text & "')"
' 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Set CN = New ADODB.Connection
CN.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & App.Path & DIR & ";" & _
"JET OLEDB:DATABASE PASSWORD=INSIDE"
CN.Execute (VLB1)
CN.Close

ElseIf (Form5.Combo3.Text = "2 VERIF. DE LINEAS BASES" And Text5.Text <> "" And Text105.Text = "" And Text127.Text = "") Then
'CUANDO ESTAN LLENOS POR COMPLETO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1
VLB1 = "INSERT INTO verificacion_LB(Clave_de_Control,Fecha_Actividad, ClavOp, Clavpar, ClavEstacion, No_Serie_Modelo_Analizador, UltimafechadeCa_Ana, No_Serie_Modelo_Calibrador, Fecha_Cal, No_serie_AireCero, Fecha_Mant, clavAct, Ana_LB_Ant,Ana_LB_Des,Cambiofiltro, Observaciones,PMT_LBAnt, PMT_LBDes)VALUES('" & Text1.Text _
& " ', '" & MaskEdBox1.Text & "','" & Combo2.Text & "','" & Label15.Caption & "','" & Combo1.Text & "','" & Combo7.Text & "','" & MaskEdBox3.Text & "','" & Combo8.Text & "','" & MaskEdBox4.Text & "','" & Combo5.Text & "','" & MaskEdBox5.Text & "','" & Combo3.Text & "','" & Text3.Text & "','" & Text5.Text & "','" & Combo4.Text & "','" & Text28.Text & "','" & Text58.Text & "','" & Text59.Text & "')"
' 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Set CN = New ADODB.Connection
CN.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & App.Path & DIR & ";" & _
"JET OLEDB:DATABASE PASSWORD=INSIDE"
CN.Execute (VLB1)
CN.Close

Gracias por revisar el código y por sus sugerencias.

Saludos.

Nota: tal vez si pudieran copiar el código en Word y verlo en una hoja horizontal pudieran verlo mejor.

Saludos cordiales
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