
August 8th, 2003, 10:22 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Where Statement
I am wiring a simple program in VB6 using Microsfot Access 87 as my database. I have a SQL statement to query the database.
In VB I have a string variable called sSQL. This string I am using to store my SQL statment. Thsi statement works.
sSQL = "SELECT * FROM Cusomer WHERE Customer.name = 'susan' "
if i try using a variable name = "susan"
sSQL = "SELECT * FROM Customer WHERE Customer.name = " & name
I am getting this error mesasage Run-Time error -214721904(800040e10) Microsoft ODBC Access97 Driver] Too few parameter Expect 1.
I have looked up this error message and it says that the field name used in the SQL statemnet is not the same as teh field bname in the Table. I have checked this, and it is correct. So I think it have to do with the syntax for using a varibale . Can some one please tell me how to use a Select Stament with WHere and a variable that contain a string. If that information I am looking for is an Integer. The statement works.
This works
i = 2 where i is an integer
sSQL = "SELECT * FROM Cusomer WHERE Customer.id = " & STR(i)
Thanks in advance
Valerie
|