Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I get an exception telling me I have a syntax error in my UPDATE statement, but I can't find it.

Dim con1 As New OleDbConnection
Dim cmd As New OleDbCommand

con1.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =C:\db.mdb"
cmd.Connection = con1
cmd.CommandText = "UPDATE tblArtikujt SET (Grupi=@Grupi, Pershkrimi=@Pershkrimi, Cmimi=@Cmimi) WHERE Id = " & ida & " "
cmd.Parameters.AddWithValue("@Grupi", TextBox2.Text)
cmd.Parameters.AddWithValue("@Pershkrimi", TextBox3.Text)
cmd.Parameters.AddWithValue("@Cmimi", TextBox4.Text)

MsgBox("Record added succesfully")
Updated 18-Dec-09 2:09am

You idiot. I've been answering you, and yet you posted the same question AGAIN. Posting the same question twice dilutes people's ability to help, because people try to answer on two threads, and don't see what other people have said. It also is rude of you to ask the same thing twice, once you've asked for free help, you should sit back and wait, unless you want to edit your original post to provide more detail.

As I said in the other thread you posted ( the first one ), I am glad you learned about paramaterised queries and fixed that, although your variable names are still retarded, making your code hard to read and debug. If you have more than one tag ( which you often should ), you place them ALL in the one post, you don't post the question over and over, with one tag per post. Now, you should build the SQL that you'd expect this query to generate ( or look at the exception object to find the SQL ), and then run that in Management Console to see if you can get a more detailed error. If that doesn't help, try posting the values you use for the three textboxes AND the schema of the database table, if you want more help.

I can't believe you did this, even as I've been trying to help you. That's just so rude, even for someone asking programming questions from the third world and hoping we'll do their work for them.
Share this answer
Who are we?

Most of us are working professionals who are usually paid good money to solve programming problems. Some of us, some of the time, choose to answer questions because we support the idea of passing knowledge on.

If you would like to guarantee a response from a working professional, i suggest that you use CP's job board and make sure to mention how much you are willing to pay not to be ignored.
Share this answer
"Firstly i am just a beginner and you are using some terms that offends us.If you are programming since 1988... thats why I have respect ok.So peace.And thnx for advices.
Putting this UPDATE tblArtikujt SET Grupi=@Grupi, Pershkrimi=@Pershkrimi, Cmimi=@Cmimi WHERE Id =' " & ida &"' i got this error Must declare the scalar variable "@Grupi""

It's like you're some kind of retard. You asked this TWICE. In one reply, I did everything I could to try to help you. The other, I edited because it's RUDE to ask the same thing twice AND it diverts the efforts of people trying to help you. You should ask each question ONCE. That is what I've been trying to tell you. If you're too mentall challenged to get that, then I'll make a note not to help you at all anymore. But, so long as you ask the same thing over and over, I will edit your posts for deletion, this forum will eventually let me delete posts, I believe. If it ever does, I would delete a duplicate, and STILL try to help on the original post.

I suspect you're too stupid to be a programmer. You seemed to get the SQL injection thing quickly, but your determination to ignore my comments and have your question posted twice, PLUS the fact that I could have helped quicker except that you didn't tell us the actual error message ( although even then, you still appear to have not done what I suggested to try to work out the issue ), make me wonder how you got so far, and then descended into a puddle of worthlessness.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900