|
-
August 1st, 2010, 04:25 PM
#1
VB6 SQL 'WHERE' statement problem
Hi
Sorry that this may seem a little spammy for a first post, but I am literally tearing my hear out here (well, I would be were it not for the fact that I'm going very bald already...)
I've done an Internet search, and have seen that this problem is quite a common one, but nowhere does it give an option that seems to show what the fix is.
My query comes with working with databases and SQL. Now, usually I don't bother using databases with VB, and if this case is anything to go by that was quite a wise thing to do. But this is a database I'm tapping into for another reason. I do use SQL when I'm doing web stuff in PHP, but not VB.
Anyhoos.
I have taken some source code from here: http://www.timesheetsmts.com/adotutorial.htm.
The first connection string works which is a simple 'SELECT * FROM table1;' command.
The second one doesn't work which is also a simple 'SELECT * FROM table2 WHERE id BETWEEN 0 AND 29;' command.
I do seem to have put this down to the WHERE statement which is knocking the problem out - error -2147217904 (80040e10): No value given for one or more required parameters.
The error is occuring on the rstRecordSet.Open cmdCommand line, but I know it's not that line that is causing problems fully as I use exactly the same line of code elsewhere (for the first connection string) which works.
I have tried putting the table and 'column' names in square brackets, putting the 'id BETWEEN...' into normal parentheses, taking out the fact that originally the 0 and 29 were put in by VB (the code currently is hardcoded to put those values in), putting 'table2' and 'id' in inverted commas, as with the 0 and 29 (despite them being integers in both the code and the Access database) - all things that my trawl through the Internet has come up with - I've also tried only putting in 'WHERE id = 1' (therefore only returning one result - this is the first time I've attempted to use the BETWEEN statement, probably a not great installation to start with! - and the only thing that stops that error coming up is to truncate the statement before the 'WHERE' - which leads me to think that it is there WHERE that is causing the problem.
I am at my wits end here with this now - all I want to do is get this to work and I cannot think of anything that is causing it not to. The SQL statement is correctly formed and it's just not working... and I'm rather pi... well I won't say that given that it's my first post and don't want to make such an impression on it, but hopefully you understand my angst!!!
Please help me!!! (I don't often say that...)
Thanks in advance
Fairy's Dad
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
|