Current location: Hot Scripts Forums » Programming Languages » ASP » SQL Statement problem


SQL Statement problem

Reply
  #1 (permalink)  
Old 08-15-04, 09:44 AM
jetskibum jetskibum is offline
New Member
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
SQL Statement problem

I have a form to enter in a vehicle license plate (could be numbers and/or letters) and it sends to my ASP page. (This does work)

However, it seems it only wants to give me results when I use the record number (not the plate text).

Does anyone know what the problem is?



--------------------------------------------------------------------------------------------------

<%

'Dimension variables

Dim adoCon 'Holds the Database Connection Object

Dim rsplate 'Holds the recordset for the records in the database

Dim strSQL 'Holds the SQL query for the database

Dim strplate



'Read call number entered from plate.asp

strplate = Request.Form("plate")



'Create an ADO connection odject

Set adoCon = Server.CreateObject("ADODB.Connection")



'Set an active connection to the Connection object using a DSN-less connection

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("cad.mdb")



'Set an active connection to the Connection object using DSN connection

'adoCon.Open "DSN=cad"



'Create an ADO recordset object

Set rsplate = Server.CreateObject("ADODB.Recordset")



%>

<%

'Initialise the strSQL variable with an SQL statement to query the database

strSQL = "SELECT tblVehicle.Vehicle_Autonumber, tblVehicle.Vehicle_License FROM tblVehicle WHERE Vehicle_License = " & strplate & " ;"



'Open the recordset with the SQL query

rsplate.Open strSQL, adoCon



'Loop through the recordset

Do While not rsplate.EOF





Response.Write (rsplate("Vehicle_Autonumber"))%><BR><%

Response.Write (rsplate("Vehicle_License"))%><BR><%







'Move to the next record in the recordset

rsplate.MoveNext



.....
I have also changed to single ' ' around " & strplate & " , which doesnt produce an error, but, doesnt print any text.
Reply With Quote
  #2 (permalink)  
Old 08-16-04, 06:41 AM
chirag's Avatar
chirag chirag is offline
Newbie Coder
 
Join Date: May 2004
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

I suggest you should check...
If strplate is alphanumeric in database you must place single quote around strplate.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL infinite loop problem with VB application Syed Visual Basic 2 05-07-04 10:19 AM
SQL Statement Ajtessin ASP 2 03-26-04 04:02 AM
Problem Dealing with Null Valuers in SQL Query hai_anilreddy Visual Basic 3 02-08-04 08:39 AM
Help with ASP & FORMS blessedrub ASP 0 01-23-04 10:22 AM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 03:00 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.