|
|
Question : Stored Proc Newbie: cant use .movefirst method
|
|
I'm converting an asp intranet site from using access and embedded sql to using sql server and stored procedures, partly to ensure longevity for the site, partly as a learning experience for myself.
old embedded sql: 'Set rs = Server.CreateObject("ADODB.Recordset") 'sql = "select tblReminder.*, tblBrand.id as BrandId, shortname, icon from tblReminder, tblBrand where tblBrand.id=tblReminder.brand and dateRemind <= '" & InsertDateStr(date) & "' and bIsDeleted=0 and username='" & lcase(username) & "' order by dateRemind" 'rs.open sql, cnCRM
new "use a stored proc" code Set cmd = Server.CreateObject("ADODB.Command")
cmd.activeconnection = cnCRM cmd.commandtext = "crmGetRemindersForUser" cmd.commandtype = adCmdStoredProc cmd.Parameters.Append cmd.createParameter("username", adChar, adParaminput, 40, sUsername) Set rs = cmd.execute
Stored Proc: CREATE PROCEDURE crmGetRemindersForUser @username varchar(40)
AS SELECT r.*, b.id AS BrandId, b.shortname, b.icon FROM tblReminder r INNER JOIN tblBrand b ON r.brand = b.id WHERE r.dateRemind <= getdate() and r.bIsDeleted=0 and r.username=@username ORDER BY r.dateRemind GO
now, a s amatter of course in prettyy much all my code, I do this: if rs.eof then response.write("No Reminders for user " & sUsername & " | " & vbcrlf) else rs.movefirst do until rs.eof 'stuff rs.movenext loop end if 'etc
Now the question is, confirming I was definately at the right point by using rs.movefirst generated an error: Error Number: -2147217896 Error Source: Microsoft OLE DB Provider for ODBC Drivers Error Description: Rowset position cannot be restarted.
Why can't I use movefirst? How can I?
I'm also having problems with dates, but thats another question. ^_^
|
Answer : Stored Proc Newbie: cant use .movefirst method
|
|
I must claim that I don't know VB but as uptill now nobody answers. Here are some guess.
1. It may be unnecessary. simply remove it rs.movefirst
2. maybe You should try Set rs = cmd.open in place of Set rs = cmd.execute
|
|
|
|
|