更新在vb.net中不起作用 [英] updation does not work in vb.net

查看:73
本文介绍了更新在vb.net中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在更新查询下面触发时,它显示错误:

关键字"where"附近的语法不正确

When I fire below update query, it displays error:

Incorrect syntax near the keyword ''where''

adp = New SqlDataAdapter("update tbl1 set name=" & "''" & TextBox2.Text & "''" & "," & "where no=" & TextBox1.Text & "", cn)

推荐答案

数据库中可能不是字符串值.
您需要编写where no=''" & TextBox1.Text & "''".
no probably is a string value in your database.
You need to write where no=''" & TextBox1.Text & "''".


而不是:
adp = New SqlDataAdapter("update tbl1 set name=" & "''" & TextBox2.Text & "''" & "," & "where no=" & TextBox1.Text & "", cn)



试试:



Try:

adp = New SqlDataAdapter("update tbl1 set name=" & "''" & TextBox2.Text & "''" & " where no=" & TextBox1.Text & "", cn)



您在哪里出了问题之前给了逗号.像我一样删除它,并在WHERE子句之前放置一个空格,应该将其全部设置为可用.



You gave a comma before where which is wrong. Remove it and put a space before WHERE clause as I did and it should be all set to go.


这篇关于更新在vb.net中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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