hello everyone,
i'm newbie to ado, i wrote the folowing code, and i get
an error message on the bold row:
" method 'open' of object '_recordset' failed"
my code is:
Dim oCn As ADODB.Connection
Dim oRs As ADODB.Recordset
Private Sub cmdAdd_Click()
With oRs
.AddNew
.Fields("name") = txtName.Text
.Fields("age") = txtAge.Text
.Update
End With
End Sub
Private Sub Form_Load()
Set oCn = New ADODB.Connection
Set oRs = New ADODB.Recordset
Dim sConnect As String
sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\ofir\Desktop\vb\database\VBtest.mdb"
oCn.Open sConnect oRs.Open "names", oCn, adOpenKeyset, adLockOptimistic, adCmdTable
Names is a Keyword or a Reserved word. When a Keyword is usesd to name a database object, you must surround it with square brackets in your sql statement.