D
dav
Hi, I'm trying to add new record to a foxpro free table connect to the
database by odbc. After all tests with DAO (the method don't accept '.update
') I tried with this that I found on this site but always I get :
Run-time error '-2147217900 (80040e14)'
the code is (the ole db driver has been installed):
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim fox As ADODB.Recordset
Dim szName As String
Dim szConnect As String
Dim szSQL As String
szName = "c:\folderdbf\;"
''' Create the connect string
szConnect = "Driver=Microsoft Visual Foxpro Driver;"
szConnect = szConnect & "SourceType=DBF;SourceDB="
szConnect = szConnect & szName
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Set fox = New ADODB.Recordset
cnn.Open szConnect
Set cmd.ActiveConnection = cnn
SQL = ("INSERT INTO tbl ( ID,field1,field2) " & _
"VALUES (" & Me.ID & "," & Me.field1 & "," & Me.field2 & ");")
szSQL = SQL
cmd.CommandText = szSQL
cmd.Execute
fox.Close
cnn.Close
Set fox = Nothing
Set cmd = Nothing
Set cnn = Nothing
thank you in advance
database by odbc. After all tests with DAO (the method don't accept '.update
') I tried with this that I found on this site but always I get :
Run-time error '-2147217900 (80040e14)'
the code is (the ole db driver has been installed):
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim fox As ADODB.Recordset
Dim szName As String
Dim szConnect As String
Dim szSQL As String
szName = "c:\folderdbf\;"
''' Create the connect string
szConnect = "Driver=Microsoft Visual Foxpro Driver;"
szConnect = szConnect & "SourceType=DBF;SourceDB="
szConnect = szConnect & szName
Set cnn = New ADODB.Connection
Set cmd = New ADODB.Command
Set fox = New ADODB.Recordset
cnn.Open szConnect
Set cmd.ActiveConnection = cnn
SQL = ("INSERT INTO tbl ( ID,field1,field2) " & _
"VALUES (" & Me.ID & "," & Me.field1 & "," & Me.field2 & ");")
szSQL = SQL
cmd.CommandText = szSQL
cmd.Execute
fox.Close
cnn.Close
Set fox = Nothing
Set cmd = Nothing
Set cnn = Nothing
thank you in advance