p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: Inserting paramewter in sql statements


Message #1 by "Andy" <andy@a...> on Tue, 21 Mar 2000 21:12:43 -0000
if both test and description are TEXT datatypes use:


sql="INSERT INTO tbltable (test, description) VALUES ('" & qCategoryID & "',
'" & qCategoryID & "');"

if, for example test was a NUMERIC datatype use:

sql="INSERT INTO tbltable (test, description) VALUES (" & qCategoryID & ",
'" & qCategoryID & "');"

Notice the numeric datatypes done need '

remember that the sql statement that you are sending to the database is just
a string.  Build the string accordingly.

Anothing thing to note, is that if your on sql server you should really
consider useing stored procedures for doing most of your sql work, including
inserts and updates.  they are more secure and are allot faster.




-----Original Message-----
From: Andy
Sent: Tuesday, March 21, 2000 1:13 PM
To: How To
Subject: [proasp_howto] Inserting paramewter in sql statements


Hi

I have the following sql statement (only test stuff the full query is long)
sql="INSERT INTO tbltable (test, description) VALUES (qCategoryID,
qCategoryID);"
where qCategoryID is a variable on a page.
I get the following error ' Too few parameters. Expected 1' - I believe (
from my VB days) that this is because I need some quotes around the
parameters . can any one help I've tried all sorts. Also how do I enclose
different datatypes ie in VB date are #date#.
Andy G

  Return to Index