cannot insert data into database - item_open event

K

Karen

I want to insert a record into the database when an outlook form is opened,
but it doesn't work.
I discover that the SQL query works for SELECT statement but does not work
in INSERT or UPDATE statement.
Is this normal? thanks

' Doesn't work..
Function Item_Open
Set myDB = CreateObject("ADODB.Connection")
strConnection = "Server=192.168.5.33;DSN=Book;Database=Book;"
strConnection = strConnection & "UID=tester;PWD=test"
myDB.Open strConnection
strSQL = "INSERT INTO Sheet1 ([book1]) VALUES ('LOTR')"
Set myRS = myDB.Execute(strSQL)
End Function


' works perfectly
Function Item_Open
Set myDB = CreateObject("ADODB.Connection")
strConnection = "Server=192.168.5.33;DSN=Book;Database=Book;"
strConnection = strConnection & "UID=tester;PWD=test"
myDB.Open strConnection
strSQL = "SELECT * From Sheet1 Where ID=3"
Set myRS = myDB.Execute(strSQL)
MsgBox myRS.fields("book1")
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top