ADO - Addnew - Error

Hermesnunya
11-01-2004, 03:10 PM
Hello All,

I think this should be an easy answer, but I was not able to find it in the tutorial nor by searching the forums.

I am getting an error "3251 Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."


Set MyConn = New ADODB.Connection

MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & NRSTATdblocation & ";"
MyConn.open

Set MyRecSet = MyConn.Execute("SELECT * FROM TestRecords")
MyRecSet.AddNew


I have tried changing the locktype with, but both of these cause different errors:

MyRecSet.LockType = adLockOptimistic
Set MyRecSet = MyConn.Execute("SELECT * FROM TestRecords")


Set MyRecSet = MyConn.Execute("SELECT * FROM TestRecords")
MyRecSet.LockType = adLockOptimistic


Any suggestions?

I couldn't get the INSERT INTO SQL to work. Probably something wrong with the statement... there's 48 fields that I have to make sure to write in correctly.


Thanks,
Jason

noi_max
11-01-2004, 03:17 PM
This may be waaaay off base, but have you set the CursorType?


MyConn.CursorType = adOpenKeyset


Like I said, that may be totally wrong. It's been a while :o

loquin
11-01-2004, 03:29 PM
You must use the Recordset.Open method if you wish to have a recordset that supports updating.

Hermesnunya
11-01-2004, 03:37 PM
Yup, this works now.


Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & NRSTATdblocation & ";"
MyConn.open

Set MyRecSet = New ADODB.Recordset
MyRecSet.CursorLocation = adUseClient
MyRecSet.open "SELECT * FROM TestRecords", MyConn, adOpenKeyset, adLockPessimistic
MyRecSet.AddNew


Thanks,
Jason

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum