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!

[b]UpdatingOracle table from VB[/b] 1

Status
Not open for further replies.

tatochka

Programmer
May 3, 2001
49
0
0
US
I need to add and delete data in oracle table from VB app. Here is my code:

*************************************
Dim cnn As ADODB.Connection
Dim rsIhdaDoc1 As ADODB.Recordset

Set cnn = New ADODB.Connection
cnn = "Provider=MSDAORA;Password=password;User ID=userid;Data Source=test;Persist Security Info=True"

cnn.Open
Set rsIhdaDoc1 = New ADODB.Recordset

rsIhdaDoc1.LockType = adLockOptimistic
rsIhdaDoc1.CursorType = adOpenDynamic
rsIhdaDoc1.Open "IHDA_DOC", cnn, , , adCmdTable

rsIhdaDoc1.AddNew
With rsIhdaDoc1
.........
rsIhdaDoc1.Update
End With
**********************************************

It stops at AddNew and gives me a message "Runtime error 3251. Current recordset doesn't support updating. This may be the limitation of the provider or selected locktype"

Can somebody tell me what should I do to make it updateable? Thanks.


 
Are you sure that the user has INSERT permisson on the IHDA_DOC table?
 
Well it would probably work then if you just construct an INSERT statment and use the connection's .Execute() method.

Another thing to try might be calling it like this:
rsIhdaDoc1.LockType = adLockOptimistic
rsIhdaDoc1.CursorType = adOpenDynamic
rsIhdaDoc1.CursorLocation = adUseClient
Set rsIhdaDoc1.ActiveConnection = cnn
rsIhdaDoc1.Open "SELECT * FROM IHDA_DOC WHERE 1=2"


Also be sure to check to make sure that cnn.State = 1 and cnn.Errors.Count = 0 and also that rsIhdaDoc1.State = 1
 
Thank you very much Sheco for all your help. I changed the code to:

' Open connection.
Set cnn = New ADODB.Connection
cnn = "......"
cnn.Open

' Open recordset
Set rsIhdaDoc1 = New ADODB.Recordset
rsIhdaDoc1.LockType = adLockOptimistic
rsIhdaDoc1.CursorType = adOpenDynamic
rsIhdaDoc1.CursorLocation = adUseClient
Set rsIhdaDoc1.ActiveConnection = cnn
rsIhdaDoc1.Open "Select * from IHDA_DOC"


and it works now. Although I don't understand what's the difference :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top