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
Showing posts with label recordset. Show all posts
Showing posts with label recordset. Show all posts
Tuesday, March 20, 2012
Monday, March 19, 2012
Cannot obtain recordset from stored procedure that contains Exec c
Hopefully someone can help. Using vbscript and ADO, I can call a very simpl
e
stored procedure that returns a recordset w/o any problems. However, when I
call a stored procedure that stuffs records into another table using a SQL
string built and the Exec command and then select the records from that
table--ADO always reports the recordset is closed.
The stored procedure works fine in Query Analyzer. It also doesn't matter
if table is temp or permanent. My workaround is to first call the stored
procedure followed by a second call to get the records. My goal is to use a
temp table in the stored procedure.
Psuedo code of stored procedure (which also uses cursor):
declare @.sqlstr varchar (100)
set @.sqlstr = 'insert into tmptable select field from anothertable'
exec(@.sqpstr)
select * from tmptableAre you setting SET NOCOUNT ON at the begining of the sp?
AMB
"reedholm" wrote:
> Hopefully someone can help. Using vbscript and ADO, I can call a very sim
ple
> stored procedure that returns a recordset w/o any problems. However, when
I
> call a stored procedure that stuffs records into another table using a SQL
> string built and the Exec command and then select the records from that
> table--ADO always reports the recordset is closed.
> The stored procedure works fine in Query Analyzer. It also doesn't matter
> if table is temp or permanent. My workaround is to first call the stored
> procedure followed by a second call to get the records. My goal is to use
a
> temp table in the stored procedure.
> Psuedo code of stored procedure (which also uses cursor):
> declare @.sqlstr varchar (100)
> set @.sqlstr = 'insert into tmptable select field from anothertable'
> exec(@.sqpstr)
> select * from tmptable
>
e
stored procedure that returns a recordset w/o any problems. However, when I
call a stored procedure that stuffs records into another table using a SQL
string built and the Exec command and then select the records from that
table--ADO always reports the recordset is closed.
The stored procedure works fine in Query Analyzer. It also doesn't matter
if table is temp or permanent. My workaround is to first call the stored
procedure followed by a second call to get the records. My goal is to use a
temp table in the stored procedure.
Psuedo code of stored procedure (which also uses cursor):
declare @.sqlstr varchar (100)
set @.sqlstr = 'insert into tmptable select field from anothertable'
exec(@.sqpstr)
select * from tmptableAre you setting SET NOCOUNT ON at the begining of the sp?
AMB
"reedholm" wrote:
> Hopefully someone can help. Using vbscript and ADO, I can call a very sim
ple
> stored procedure that returns a recordset w/o any problems. However, when
I
> call a stored procedure that stuffs records into another table using a SQL
> string built and the Exec command and then select the records from that
> table--ADO always reports the recordset is closed.
> The stored procedure works fine in Query Analyzer. It also doesn't matter
> if table is temp or permanent. My workaround is to first call the stored
> procedure followed by a second call to get the records. My goal is to use
a
> temp table in the stored procedure.
> Psuedo code of stored procedure (which also uses cursor):
> declare @.sqlstr varchar (100)
> set @.sqlstr = 'insert into tmptable select field from anothertable'
> exec(@.sqpstr)
> select * from tmptable
>
Subscribe to:
Posts (Atom)