Click to See Complete Forum and Search --> : Cursor Location


Webskater
10-02-2003, 07:31 AM
If I create a recordset in this manner:

SET HelpCmd = Server.CreateObject("ADODB.Command")
HelpCmd.CommandType=adCmdStoredProc
SET HelpCmd.ActiveConnection=HelpDB
HelpCmd.CommandText="EmployeeSearchByName"
HelpCmd.Parameters.Append HelpCmd.CreateParameter("UserName", adVarChar, adParamInput,30, CStr(TRIM(Name)))
HelpCmd.Parameters.Append HelpCmd.CreateParameter("CompanyID", adInteger, adParamInput,, CLng(Session("CoID")))
SET EmpRS = HelpCmd.Execute
SET HelpCmd = nothing

Is it possible to set the Cursor Location to client? and, if so, how?
Thanks for any help.

rdoekes
10-02-2003, 10:38 AM
Change:

SET EmpRS = HelpCmd.Execute
SET HelpCmd = nothing

To

Set EmpRS = Server.CreateObject("ADODB.RecordSet")
EmpRS.CursurLocation = adUseClient
Set EmpRs = HelpCmd.Execute

Webskater
10-03-2003, 09:24 AM
Thanks for your reply.
I was originally opening the recordset as you described but using the open method to create the RS. This worked and I could use RecordCount.
I changed it to open using execute against an ADODB.command because of difficulties with inverted commas in the parameters. After I changed the method of creating the recordset, RecordCount now returns -1 ie. the cursor is not client side.
So, using ....
Set EmpRS = Server.CreateObject("ADODB.RecordSet")
EmpRS.CursurLocation = adUseClient
... Create SQLString with parameters and then using: ...
EmpRS.open SQLString, ConnectionObject
This worked and RecordCount returns no. of records in EmpRS.

However, using ...
Set HelpCmd = Server.CreateObject("ADODB.Command")
Set EmpRS = Server.CreateObject("ADODB.RecordSet")
EmpRS.CursurLocation = adUseClient
... Create Parameters ...
Set EmpRS = HelpCmd.execute
This creates EmpRS but RecordCount does not work.

rdoekes
10-03-2003, 09:41 AM
I never use the command object myself, and the problem of inverted commas can be solved using a very simple function:

Function ReplaceQuotes( _
ByVal StringParameter as string) as String

ReplaceQuotes = "'" & _
Replace(StringParameter, "'", "''") & "'"
End Function

You call this function when building SQL:

SQLString = "EmployeeSearchByName " & _
" @UserName = " & _
ReplaceQuotes(CStr(TRIM(Name))) & _
", @CompanyId = " & _
CLng(Session("CoID"))
Set EmpRS = Server.CreateObject("ADODB.RecordSet")
EmpRS.CursurLocation = adUseClient
EmpRS.open SQLString, ConnectionObject