Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid operation. (Error 3219)

Status
Not open for further replies.

goobil

Technical User
Aug 9, 2003
38
0
0
AG
Invalid operation. (Error 3219)
I am getting this error when using the insert into statement in VB6.
The data engine is DAO to connect to access2003 database.
I tries the select * statement and that work find.

My question to all is why it’s not inserting new record to the database?

Form
Option Explicit

Private Sub cmdtest_Click()
Call DataOpen ‘************ Call the data base *********************
Dim strSQL, xtest1, xtest2 As String
'Dim rsdb As DAO.Recordset
Dim rsdb As ADODB.Recordset

xtest1 = "this is just a test1"
xtest2 = "test is just a nother test"
'strSQL = "SELECT test1, test2 FROM test"
strSQL = "Insert into test(test1, test2)Values('" & xtest1 & "', '" & xtest2 & "')"
Set rsdb = gdb.OpenRecordset(strSQL)
End Sub

Data MODULE

Option Explicit
Public gdb As Database
'Public gdb As Database
Public gstrDatabase As String


'Public Function DataOpen() As Boolean
Public Function DataOpen() As Integer
gstrDatabase = (App.Path & "\data.mdb")

Set gdb = DBEngine.Workspaces(0).OpenDatabase(gstrDatabase)
DataOpen = True
End Function
 
use the execute statement, not openrecordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top