Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public cn As ADODB.Connection
  4. Public rs As ADODB.Recordset
  5.  
  6. Public Sub Conectar()
  7. Set cn = New ADODB.Connection
  8. Set rs = New ADODB.Recordset
  9. rs.CursorLocation = adUseClient
  10. cn.Open "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=gestvehicular; User=root;Password=123456;Option=3;"
  11. End Sub
  12.  
  13. Private Sub btnGuardar_Click()
  14.  
  15.  
  16. If txtNombre.Text <> "" Then
  17. Dim strSql As String
  18. strSql = "INSERT INTO gvehi_colores(descripcion) VALUES('" + txtNombre.Text + "')"
  19. On Error GoTo tratarError
  20. Dim cmd As New Command
  21. Conectar
  22. With cmd
  23. .ActiveConnection = cn
  24. .CommandText = strSql
  25. .CommandType = adCmdText
  26. .Execute
  27. End With
  28. On Error GoTo 0
  29. Desconectar
  30. Exit Sub
  31. tratarError:
  32. MsgBox Err.Description
  33. End If
  34. End Sub
  35.  
  36. Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase;
  37. User=myUsername;Password=myPassword;Option=3;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement