I am using asp(vb)
In SQL Server database I made a table cars which has two columns:
productid intname varchar(50)
Now I am collecting the value of name attribute from user through a text field:
Enter car name
<input type="text" name="name" value="" />
and storing it in a variable:
name = Request.Form("name")
But when I run this query, it gives error:
query = "SELECT * FROM cars where name = " & name
Unable to figure out why?
Because
nameis defined as aVARCHARstring datatype, this would mean you need to quote the value ofnamein your SQL query, ieor better still, use a parameterised query via a
ADODB.Commandobject if you’re using ADODB