|
-
July 25th, 2009, 06:57 AM
#1
[RESOLVED] Sql Statement issue
Can anyone tell me.why this sql statement is not working.Any help would be highly appreciated.
here is the following statement.
Code:
strsql = " SELECT *" & _
" From ALRAJHIBANK " & _
" WHERE (((ALRAJHIBANK.ID)= & itemID & ))"
Meanwhile this is working properly.
Code:
strsql = " SELECT *" & _
" From ALRAJHIBANK " & _
" WHERE (((ALRAJHIBANK.ID)=3))"
-
July 25th, 2009, 08:15 AM
#2
Re: Sql Statement issue
strsql = " SELECT *" & _
" From ALRAJHIBANK " & _
" WHERE (((ALRAJHIBANK.ID)= " & itemID & "))"
-
July 25th, 2009, 09:04 AM
#3
Re: Sql Statement issue
When you use some variable inside one SQL statement, you should close quotes and concat with it.
"SELECT * FROM " & sTESTE & " WHERE X = 1"
-
July 25th, 2009, 09:36 AM
#4
Re: Sql Statement issue
Post number 2 has the correct solution. The second statement is not formated properly and as a result instead of placing the content of the itemId var into the statement it is placing & itemId &
@firoz.raj When you run into an issue such as this you should either set a break point and look at the content of the strsql, or add a line to display this var in a message box or a debug.print statement. If you would have done any of these you would have most likely found your error in seconds.
Last edited by DataMiser; July 25th, 2009 at 09:38 AM.
-
July 25th, 2009, 11:41 AM
#5
Re: Sql Statement issue
Also when dealing with SQL Statements within your VB code, it is always better to use parametrized queries. They give you more control and are compiled and secure.
Take a look at this sample
http://www.codeguru.com/forum/showpo...53&postcount=4
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
|