|
-
Mar 17th, 2010, 06:59 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Sintax error (comma)...
When I'm trying to update or remove record from database I'm getting this error:
Code:
Syntax error (comma) in query expression 'Ime='Blagojce', Prezime='', Adresa='', Grad='', Telefonski_br='( ) -', Fax='( ) -', e_mail='''
Here is my connection string:
Code:
command.CommandText = "DELETE * FROM podatoci WHERE Ime='" & ime & "', Prezime='" & prezime & "', Adresa='" & adresa & "', Grad='" & grad & "', Telefonski_br='" & broj & "', Fax='" & fax & "', e_mail='" & email & "'"
where ime, prezime and so on are ListView selected items.
-
Mar 17th, 2010, 07:14 AM
#2
Re: Sintax error (comma)...
You have a single quote in your email field. You should either escape it with another single quote (i.e. replace single quote with 2 single quotes), or use parameterized query.
e.g.
Code:
email = email.Replace("'", "''")
command.CommandText = "DELETE * FROM podatoci WHERE Ime='" & ime & "', Prezime='" & prezime & "', Adresa='" & adresa & "', Grad='" & grad & "', Telefonski_br='" & broj & "', Fax='" & fax & "', e_mail='" & email & "'"
-
Mar 17th, 2010, 07:18 AM
#3
Re: Sintax error (comma)...
Also you encountered a problem with email doesn't rule out the rest of them. As a safety you will have to do that for all variables as I have shown in the above code for email.
-
Mar 17th, 2010, 07:23 AM
#4
Re: Sintax error (comma)...
Ummmm.... that's not the problem..... the whole where clause is wrong...
you want to delete from your table WHERE a field matches AND another field matchs AND another AND so on....
You can't use commas between fields like that in a where.... you have to use AND, or OR depending on if you want any match or all to match.
-tg
-
Mar 17th, 2010, 11:47 AM
#5
Re: Sintax error (comma)...
AAhhh... I see.
I just saw your error message and jumped to conclusion.
tg is right. You don't have the ANDs and ORs in your WHERE clause of the query.
-
Mar 17th, 2010, 02:27 PM
#6
Thread Starter
Addicted Member
Re: Sintax error (comma)...
I changed commas with AND clause and now it works.
Thanks to all!
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
|