Hi,
I am using ASP to connect to an MS SQL database. The script connects to the database OK and I can retrieve recordset data and add new rows without a problem.
However, when I try to edit a recordset (using the recordset.update command), I get the following error:
Cannot open database requested in login 'andthen_development'. Login fails.
My first thought was that it must be a permissions problem, but that doesn't explain why I can view and add rows, but not edit. Any ideas?
Thanks, Pauldid you try an "Update" command
objCommand.ActiveConnection = objConnection objCommand.CommandText = "Update Table tbl set ..."
Call objCommand.Execute
just see if this works with your login
or try updating with the QA and your login|||then we'll see why the RecordSet.Update doesn't work|||Just tried an "UPDATE TABLE..." command directly and it works fine. However, I have an ASP include file that I use to handle all database functionality centrally. Included in this is the following function:
Function editRow(sqlString, rowParameters)
'#-- UPDATES AN EXISTING DATABASE ROW
'#-- SET UP RECORDSET FOR EDITING A RECORD
Set recordSet = Server.CreateObject("ADODB.RecordSet")
recordSet.CursorLocation = adUseServer
recordSet.CursorType = adOpenForwardOnly
recordSet.LockType = adLockOptimistic
recordSet.Open sqlString, connection, , ,adCmdText
'#-- ITERATE THROUGH rowParameters TO UPDATE ITEM'S FIELDS
Dim rowField
For Each rowField In rowParameters
recordSet(rowField) = rowParameters.Item(rowField)
Next
'#--UPDATE RECORDSET (UPDATE RECORD)
recordSet.Update
End Function
The function accepts an SQL string to identify the row (e.g. "SELECT * FROM...") and a Dictionary object that contains keys relating to field names and values giving the new contents for the row.
This produces an error on the recordset.Update line.
Paul|||maybe it's the cursor location
or one of the option of the recordset
Set recordSet = Server.CreateObject("ADODB.RecordSet")
recordSet.CursorLocation = adUseServer
recordSet.CursorType = adOpenForwardOnly
recordSet.LockType = adLockOptimistic
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment