Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public cn As ADODB.Connection
- Public rs As ADODB.Recordset
- Public Sub Conectar()
- Set cn = New ADODB.Connection
- Set rs = New ADODB.Recordset
- rs.CursorLocation = adUseClient
- cn.Open "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=gestvehicular; User=root;Password=123456;Option=3;"
- End Sub
- Private Sub btnGuardar_Click()
- If txtNombre.Text <> "" Then
- Dim strSql As String
- strSql = "INSERT INTO gvehi_colores(descripcion) VALUES('" + txtNombre.Text + "')"
- On Error GoTo tratarError
- Dim cmd As New Command
- Conectar
- With cmd
- .ActiveConnection = cn
- .CommandText = strSql
- .CommandType = adCmdText
- .Execute
- End With
- On Error GoTo 0
- Desconectar
- Exit Sub
- tratarError:
- MsgBox Err.Description
- End If
- End Sub
- Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase;
- User=myUsername;Password=myPassword;Option=3;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement