hello all

i am facing a problem when i try to add new records in to data base. first of all my tech details are given below

Front end - vb 6
Back end - Microsoft SQL Server 2000

i am connecting to sql through ADODB connection ( through code ). my purpose is when i click on the "ok" button then the records entered in my form will add to the database. but when i click on the ok button then a errors comes saying

" Run-time error '-2147217840(80040e4e)'
operation was canceled "

and the error is highlighted in adorset.Move 0

my code is like this

If (MsgBox("Are You Sure? You Want to Save The Record?", vbYesNo) = vbYes) Then
adorset.Move 0
adorset.Update
MsgBox "Record Saved"
Call rsEmpC
Call constateC
Unload Me
End If
End Sub

one of the funniest thing is that if we press debug and run in regular base the record will be saved in to the table

please help me

Do you need adorset.Move 0 ?
However, you do have a connection object. Check from the connection object which is the native error and description

oConn.Errors(0).NativeError
oConn.Errors(0).Description

where oConn is your connection object.

I see. I wasn't aware of that.

However, the article suggested a solution that should solve the problem. This is, if I did understood it right. Update MDAC (latest version is 2.8) and use a client-side cursor. The article was updated 2005 for MDAC 2.5, so maybe just updating MDAC to 2.8 could solve the problem without the need to use client-side cursor. Is this possible to do or do you already have the latest MDAC?

Thanks again for your replay
but actually i am using MDAC 2.8 in my system

Then I'll refer to my first reply. At the point of error, what values does

oConn.Errors(0).NativeError
oConn.Errors(0).Description

have? oConn is your connection object. Also what type of CursorType property do you use?

i use

adorset.CursorType = adOpenDynamic
    adorset.LockType = adLockOptimistic

Ok. Here's a snippet from the code I'm using now:

Set oConn = New ADODB.Connection
ConStr = "PROVIDER=SQLOLEDB;Data Source=XXX; INITIAL CATALOG=XXXlab; User ID=XXX; Password=XXX;"
oConn.Open ConStr
...
Dim oRs As New ADODB.Recordset

oRs.CursorLocation = adUseClient
strGridSQL = "SELECT * FROM [" & XXX & "]"
oRs.Open strGridSQL, oConn, adOpenDynamic, adLockOptimistic
oRs.Move 0 ' No error here or after

adding oRs.Move 0 has no effect, in the sense that no error occurs. My dev DB is SQL Server 2005 but I doubt that makes a difference (the code has been tested and targeted to 2000).

I'm still curious about oConn.Errors(0).NativeError and oConn.Errors(0).Description values?

thank you my problem was solved. thanks for u r help, thanks a lot......

the error vanished when i use the CursorLocation as client . then no need for the move 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.