View Full Version : Help

01-25-2003, 10:55 PM
I've been trying all day to get this work, im fairly new at asp, and I need some help, im making a page that is going to take data from a access database using an sql query based on user input. Basically, i want this to display the info in a row in my table. Here is what i have, but i dont know how to get it to take the user input, what should i do

Response.Buffer = true
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:\inetpub\wwwroot\data.mdb;"
sqltext = "SELECT * FROM tbl1 WHERE id=& strType &"
set rst = cnn.Execute(sqltext)
Response.Write rst("id")
Response.Write rst("submitted_by")
Response.Write rst("date")
Response.Write rst("department")
Response.Write rst("date_required_go_live")

It works fine without the varible in there, so, please help

01-25-2003, 10:58 PM
Oh, if you need an example of what i am trying to do, here is a link:


Its the one with the drop down box

01-26-2003, 02:03 AM
Depending on the datatype of id, try either:

sqltext = "SELECT * FROM tbl1 WHERE id=" & strType


sqltext = "SELECT * FROM tbl1 WHERE id='" & strType & "'"


01-26-2003, 04:51 PM
Thanks, but, now i have a new problem, its the same type i believe, I cant get the variable to work, and I dont know why

' Setting variables
Dim con, sql_update, data_source
data_source = "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:\inetpub\wwwroot\data.mdb;"
formid = "Request.Form('prodType')"
sql_update = "update tbl1 set submitted_by = 'Update Records' where id = "& formid &""

' Creating the Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source

' Executing the sql update code
con.Execute sql_update

' Done. Now Close the connection
Set con = Nothing

I get the same error message as before

BTW, i was able to resolve my last problem

01-26-2003, 04:54 PM
Again, your SQL statement looks wrong...

sql_update = "update tbl1 set submitted_by = 'Update Records' where id = " & formid

01-26-2003, 05:07 PM
That didnt work, I changed it to what you had and got this error message:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Undefined function 'Request.Form' in expression.

01-26-2003, 05:08 PM
Try writing out your SQL statements when you get errors, i.e.:

Response.Write(SQL) : Response.End

The reason it isn't working is because of this:

formid = "Request.Form('prodType')"

Request.Form("") shouldn't have quotes around it, you're turning that into a string that equals "Request.Form('prodType')".

that line should be:

formid = Request.Form("prodType")

It looks like you're having a lot of problems with the syntax, writing out your SQL statements when they error will show you what's being generated.

01-26-2003, 05:15 PM
Didnt work again, I got this error message this time:

Syntax error (missing operator) in query expression 'id ='.

If i remove all of the variables the script works fine, the form is not inside the asp page, does it need to be? right now it is an external file

01-26-2003, 05:19 PM
Nevermind, I got it to work. Thanks for all your help