Primero entra a referencias y tilda
Microsoft Activex data Objects 2.6 librery
En un modulo realizas la conexion a la base de datos este ej se conecta a x.mdb osea access
Public Sub Access()
'*
Dim Cadena As String, NomBase As String, Ruta As String
'*
On Error GoTo 1
'*
NomBase = "x.mdb"
'*
Ruta = App.Path & "\" & NomBase
'*
Cadena = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source =" & Ruta & ""
'*
Set Ado = New ADODB.Connection
'*
Ado.CursorLocation = adUseClient
'*
Ado.Open Cadena
'*
Exit Sub
1:
Call Error
End Sub
luego en el form en el load haces
Private Sub Form_Load()
'*
On Error GoTo 1
'*
Call Access
'*
Exit Sub
1:
Call Error
End Sub
y luego en boton haces:
Private Sub Command1_Click()
Ado.BeginTrans
Ado.Execute ("Insert Into Rubros values ('" + T1.Text + "')")
Ado.CommitTrans
End Sub