我的UPDATE语句中的语法错误 [英] syntax error in my UPDATE statement

查看:191
本文介绍了我的UPDATE语句中的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个异常消息,告诉我UPDATE语句中存在语法错误,但找不到.

昏暗的con1作为新的OleDbConnection
昏暗的cmd作为新的OleDbCommand

con1.ConnectionString ="PROVIDER = Microsoft.Jet.OLEDB.4.0;数据源= C:\ db.mdb"
cmd.Connection = con1
cmd.CommandText ="UPDATE tblArtikujt SET(Grupi = @ Grupi,Pershkrimi = @ Pershkrimi,Cmimi = @ Cmimi)在哪里ID ="&ida&"
cmd.Parameters.AddWithValue("@ Grupi",TextBox2.Text)
cmd.Parameters.AddWithValue("@ Pershkrimi",TextBox3.Text)
cmd.Parameters.AddWithValue("@ Cmimi",TextBox4.Text)

con1.Open()
cmd.ExecuteNonQuery()
con1.Close()
MsgBox(记录添加成功")

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)

con1.Open()
cmd.ExecuteNonQuery()
con1.Close()
MsgBox("Record added succesfully")

推荐答案

你这个白痴.我一直在回答您,但您还是再次提出了同样的问题.两次发布相同的问题会削弱人们的帮助能力,因为人们试图在两个线程上回答,而看不到别人在说什么.您两次询问同一件事也是很不礼貌的,一旦您请求免费帮助,您应该坐下来等待,除非您想编辑原始帖子以提供更多细节.

正如我在您发布的另一个线程(第一个线程)中所说的那样,很高兴您了解到参数化的查询并修复了该问题,尽管您的变量名仍然受阻,这使您的代码难以阅读和调试.如果您有多个标签(通常应这样做),则将它们全部放置在一篇文章中,则不必一遍又一遍地发布问题,每篇文章仅包含一个标签.现在,您应该构建期望此查询生成的SQL(或查看异常对象以找到SQL),然后在管理控制台中运行该SQL以查看是否可以获得更详细的错误.如果那没有帮助,请尝试发布用于三个文本框的值以及数据库表的架构,以获取更多帮助.

即使我一直在努力帮助您,我也无法相信您这样做.即使对于从第三世界询问编程问题并希望我们为他们完成工作的人,这也是如此无礼.
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.


我们是谁?

我们大多数人都是在职专业人员,通常他们会得到丰厚的报酬来解决编程问题.我们中的某些人有时会选择回答问题,因为我们支持传递知识的想法.

如果您想保证有工作的专业人员做出回应,我建议您使用CP的工作委员会,并确保提及您愿意支付的费用,不要被忽略.
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.


首先,我只是一个初学者,您使用的某些术语会冒犯我们.如果您从1988年开始编程,这就是为什么我尊重ok.So和平.还有thnx的建议.
放置此更新tblArtikujt SET Grupi = @ Grupi,Pershkrimi = @ Pershkrimi,Cmimi = @ Cmimi WHERE Id =''&ida&"''我收到此错误必须声明标量变量"@Grupi""

就像你是某种智障.您问过两次.在一份答复中,我竭尽所能为您提供帮助.另一个是我编辑的,因为两次询问同一件事是不礼貌的,并且转移了试图帮助您的人们的精力.您应该一次问每个问题.那就是我一直想告诉你的.如果您在精神上难以接受,那么我会做笔记,以至于不再对您有任何帮助.但是,只要您一遍又一遍地问相同的问题,我就会编辑您要删除的帖子,我相信这个论坛最终会让我删除帖子.如果有的话,我会删除一个重复的副本,并仍然尝试在原始帖子上提供帮助.

我怀疑您太愚蠢了,无法成为一名程序员.您似乎很快就能得到SQL注入,但是您下定决心要忽略我的评论,并两次提出您的问题,再加上我可以更快地帮助您,但您没有告诉我们实际的错误信息(尽管即使如此,我也可以提供帮助) ,您似乎仍然没有按照我的建议尝试解决该问题),让我想知道您到目前为止如何,然后陷入了毫无价值的泥潭.
"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.


这篇关于我的UPDATE语句中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆