I am getting the following error when trying to get a recordset:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
THE CODE IN MY FUNCTION PAGE:
Set rs = Server.CreateObject("ADODB.Recordset")
Call OpenDB()
strSQL= "SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "'"
rs.CursorType = 2
rs.LockType = 2
rs.Open strSQL, objConn
strSQL= "SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "'"
rs.CursorType = 2
rs.LockType = 2
rs.Open strSQL, objConn
THE CODE IN MY CONNECTION INCLUDE:
Function OpenDB()
dim objconn
Set objConn = Server.CreateObject("ADODB.Connection")
Application("objconn_ConnectionString") = "DRIVER={SQL Server};SERVER=pls-rgriggs-2ks;DATABASE=ccb;UID=CCB;PWD=CCB"
objConn.Open Application("objConn_ConnectionString")
End Function
Any help would be greatly appreciated, I am going blind looking at this error.
Code:
SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "'"
Are you sure that ccbnum is a textfield.
See, ' = text. Check that it is a textfield and not a number.
If it is a number replace it with:
Code:
SELECT ccbnum,email FROM ccb WHERE ccbnum = " & ccbnum & " "
Hope that helps.
Was this answer helpful ?
Yes No
Quote:
| Originally Posted by rgriggs I am getting the following error when trying to get a recordset:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
THE CODE IN MY FUNCTION PAGE:
Set rs = Server.CreateObject("ADODB.Recordset")
Call OpenDB()
strSQL= "SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "';"
rs.CursorType = 2
rs.LockType = 2
rs.Open strSQL, objConn
strSQL= "SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "'"
rs.CursorType = 2
rs.LockType = 2
rs.Open strSQL, objConn
THE CODE IN MY CONNECTION INCLUDE:
Function OpenDB()
dim objconn
Set objConn = Server.CreateObject("ADODB.Connection")
Application("objconn_ConnectionString") = "DRIVER={SQL Server};SERVER=pls-rgriggs-2ks;DATABASE=ccb;UID=CCB;PWD=CCB"
objConn.Open Application("objConn_ConnectionString")
End Function
Any help would be greatly appreciated, I am going blind looking at this error. |
it's possible you do not have the
adovbs.inc in your code...these are the constants needed for your parameters, but looks like you are only dong a readly only so just use the default and have no parameters set - readonly
Code:
%>
Call OpenDB()
strSQL= "SELECT ccbnum,email FROM ccb WHERE ccbnum = " & ccbnum & ";" ' assuming a number
rs.Open strSQL, objConn
If rs.EOF then
Response.Write "No Records"
Else
Do While Not rs.EOF
Response.Write rs.("ccbnum") & " " & email
rs.moveNext
Loop
rs.Close
Set rs = nothing
objConn.Close
Set objConn = nothing
End If
%>
include
Code:
Function OpenDB()
dim objconn
Set objConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
Application("objconn_ConnectionString") = "DRIVER={SQL Server};SERVER=pls-rgriggs-2ks;DATABASE=ccb;UID=CCB;PWD=CCB"
objConn.Open Application("objConn_ConnectionString")
Was this answer helpful ?
Yes No
It is a text field and example number would be CCB501499. I have this code in a functions page and found that if
I take all other recordsets off of the page and just leave one there then it works fine. I have the problem when I add
other functions to the page that creates a recordset. All functions work fine by themselves. Also, If I don't include the connection
page and put the connection in the function it works. HMMM! I don't get it.
Hope this gives you enough info to help me solve this because I don't want to put all the functions in a page of their own. Thanks so much for you input on this.
Quote:
| Originally Posted by snipered
Code:
SELECT ccbnum,email FROM ccb WHERE ccbnum = '" & ccbnum & "'"
Are you sure that ccbnum is a textfield.
See, ' = text. Check that it is a textfield and not a number.
If it is a number replace it with:
Code:
SELECT ccbnum,email FROM ccb WHERE ccbnum = " & ccbnum & " "
Hope that helps. |
Was this answer helpful ?
Yes No
There is little point in setting an application variable to the connection string, since you are assigning it every time you enter the function OpenDB (which should really be a Sub, by the way). You should open the connection once at the start of the page, and leave it open until all code on the page is completed, i.e. don't close the connection after you get each recordset, just leave it open for use by the next query and close the connection after all database processing on the page is completed.
Was this answer helpful ?
Yes No
Thanks for the info. I was able to solve this by changing my connection page. Not sure what the problem with it was, just wrote it and now it all works. I didn't time to work through it to find the problem, just moved on when I got it working. I guess your right about the subs, I have an application that I send emails when different things happen an so wanted to keep it together on a function page so I could work in one place.
Thanks so much again for your help on this.
Quote:
| Originally Posted by splinters There is little point in setting an application variable to the connection string, since you are assigning it every time you enter the function OpenDB (which should really be a Sub, by the way). You should open the connection once at the start of the page, and leave it open until all code on the page is completed, i.e. don't close the connection after you get each recordset, just leave it open for use by the next query and close the connection after all database processing on the page is completed. |
Was this answer helpful ?
Yes No