Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Correction to SQL Statement Problem

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Greetings,

The following SQL statement works directly in SQL Enterprise Manager when I type in the values of the grad ID and/or the certificate number, but when it's in ASP using the variable, it returns all records whether I want them or not. The response object is from a text box in which the users type a certificate number or a graduate ID then submit.

dim strCert
strCert = trim(Request("cert"))

Set oRs = Server.CreateObject("ADODB.Recordset")
Set oRs = objConn.Execute("SELECT * from vw_ProfileNew WHERE (GradID = '" & strCert & "') OR (CertNum = '" & strCert & "')")

Any help or suggestions would be greatly appreciated. I'm not familiar with stored procedures, but if that's a better option, I'm open.

Thanks.

 

Are GradID and CertNum numeric or character data types. The names would indicate numeric. If so, remove the single quotes in the query string.

Set oRs = objConn.Execute("SELECT * from vw_ProfileNew WHERE (GradID = " & strCert & ") OR (CertNum = " & strCert & ")")
Terry Broadbent
Please review faq183-874.

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top