Modify file to use static cursor

Results 1 to 2 of 2

Thread: Modify file to use static cursor

  1. #1
    Join Date
    Dec 1969

    Default Modify file to use static cursor

    Hello all,<BR><BR>I have been battling with one page for a while, trying to use the COUNT function in SQL, but SQL2000 seems to hate it and keeps giving me an error.<BR><BR>I have tried using the RecordCount property, but it appears as though the function which I use to open a connection, execute some SQL, and return a recordset returns the recordset with an adOpenForward CursorType.<BR><BR>I have tried my best to modify the file to make it return with an adOpenStatic CursorType, and still no luck. I need some advice from some ADO experts.<BR><BR>Below is the file&#039;s contents:<BR><BR>[code language="VBScript"]<BR>Function adlExecuteSQL (strControlDB, strSQL, rstResults)<BR><BR>Dim cnnDB &#039; Control database connection object<BR>Dim strConnect &#039; Connection parameters<BR>Dim objError &#039; Error object<BR><BR>&#039;// Open an ADO connection to the control database.<BR><BR>Set cnnDB = Server.CreateObject ("ADODB.Connection")<BR>strConnect ="Provider=SQLOLEDB; Data Source = (local); Initial Catalog = " & strControlDB & "; User Id = phoenix; Password=aug1998"<BR>cnnDB.Open strConnect<BR><BR>&#039;// Execute specified SQL statement. Store results in temporary recordset, if any.<BR><BR>Set rstResults = cnnDB.Execute (strSQL)<BR><BR>&#039;// Close the connection and return the recordset to the caller.<BR><BR>adlExecuteSQL = True<BR><BR>Set cnnDB = Nothing<BR><BR>End Function<BR>[/code]<BR><BR>When I want to perform a query I use these:<BR><BR>[code language="VBScript"]<BR>strDB = "DatabaseName"<BR>strSQL = "SELECT SomeField FROM SomeTable"<BR>ysnSuccess = adlExecuteSQL(strDB,strSQL,NameofRecordset)<BR>[/code]<BR><BR>ysnSuccess being a boolean variable for testing purposes.<BR><BR>What do you all suggest?

  2. #2
    Join Date
    Dec 1969

    Default Check out the documentation for...

    ...SQL2000 and you&#039;ll find the answer. If you require the count, put it into your SQL statement and get the number like you would get the value for a field:<BR><BR>SELECT COUNT(SomeField) FROM SomeTable<BR><BR>Then get the value for the first field.<BR><BR>Is that what you mean?<BR><BR>Oliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts