|
-
Sep 11th, 2000, 05:36 PM
#1
This is driving me mad. I am new to VB and I am sure that this is something very simple. Please tell me why the code example 1 works and code example 2 does not when they ought to be doing the same thing.
----------------------------
This works:
Set rs = db.OpenRecordset("SELECT * FROM Street " _
& "WHERE (street.Provincia_ID = 3)")
-----------------------------
This gives run time error 3061 ("Too few parameters. Expected 1"):
dim workint as integer
workint = 3
Set rs = db.OpenRecordset("SELECT * FROM Street " _
& "WHERE (street.Provincia_ID = workint)")
----------------------------
As you can see, the only difference is that instead of the number 3 I am using a variable workint which I had set to 3 previously.
street.provincia_ID is defined as integer in the database.
Please help, is there any syntax problem or something.
-
Sep 11th, 2000, 06:05 PM
#2
Got it
Got it.. I had to do the following:
'Set up the SQL string
SQLString = "SELECT * from Street WHERE Provincia_ID = " & workint
'Get the data
Set rs = db.OpenRecordset(SQLString)
-
Sep 12th, 2000, 10:34 AM
#3
Hyperactive Member
Glad you fixed the problem. Your error was one of simple
syntaxt, though. Your variable workint should come outside
of the quotes of the SQL statement, like this:
Code:
dim workint as integer
workint = 3
Set rs = db.OpenRecordset("SELECT * FROM Street " _
& "WHERE (street.Provincia_ID = " & workint & )")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|