|
|
Question : Port from ACCESS to SQL Server throws ERRORS: Microsoft OLE DB Provider for ODBC Drivers error '80040e23' [Microsoft][ODBC SQL Server Driver]Cursor operation conflict
|
|
I have an .asp application that I moved from an MS Access backend to a SQL Server (MSDE verison) backend.
I'm now plagued with the following error anytime I have code that wants to do an rs.update
Microsoft OLE DB Provider for ODBC Drivers error '80040e23'
[Microsoft][ODBC SQL Server Driver]Cursor operation conflict ]
What gives? Why ok with Access and not SQL Server?
A sample of code that gives me such an error is:
If request.QueryString("AdvisorTo") <> "" Then
'Dim JobIdtoChange Dim sqlString5 Dim newAdvisor 'Trouble Shooting --> Response.Write(request.QueryString("JobId")) & " " Response.Write(request.QueryString("AdvisorTo")) JobIdtoChange = request.QueryString("JobId") sqlString5 = "select * from job where ID = " & JobIdtoChange newAdvisor = request.QueryString("AdvisorTo") 'Open recordset set rs = Server.CreateObject("ADODB.Recordset") rs.Open sqlString5, "DSN=dsnname;UID=user;PWD=password;DB=database_db;", adOpenDynamic, adLockOptimistic rs("AdvisorID").value = newAdvisor 'Writes the record rs.Update
'Closes the recordset rs.Close End If
|
Answer : Port from ACCESS to SQL Server throws ERRORS: Microsoft OLE DB Provider for ODBC Drivers error '80040e23' [Microsoft][ODBC SQL Server Driver]Cursor operation conflict
|
|
>>yes, I'd like to go that route. <<
If request.QueryString("AdvisorTo") <> "" Then
'Dim JobIdtoChange Dim sqlString5 Dim newAdvisor 'Trouble Shooting --> Response.Write(request.QueryString("JobId")) & " " Response.Write(request.QueryString("AdvisorTo")) JobIdtoChange = request.QueryString("JobId") sqlString5 = "select * from job where ID = " & JobIdtoChange newAdvisor = request.QueryString("AdvisorTo") 'Open recordset set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = adUseClient ' Add this line rs.Open sqlString5, "DSN=dsnname;UID=user;PWD=password;DB=database_db;", adOpenDynamic, adLockOptimistic
rs("AdvisorID").value = newAdvisor 'Writes the record rs.Update 'Closes the recordset rs.Close End If
>>I'm all for learning how to do it the 'right way', right now."<< Try it this way: Dim JobIdtoChange Dim SQL Dim newAdvisor Dim cn
newAdvisor = request.QueryString("AdvisorTo") If Len(newAdvisor) Then JobIdtoChange = request.QueryString("JobId")
'Open Connection Set cn = Server.CreateObject("ADODB.Connection") With cn .ConnectionString = "DSN=dsnname;UID=user;PWD=password;DB=database_db;" .Open ' Assuming that AdvisorID and ID are numeric SQL = "Update job Set AdvisorID = newAdvisor Where ID = " & JobIdtoChange .Execute SQL, , 128 ' adExecuteNoRecords .Close End With Set cn = Nothing End If
|
|
|
|
|