如何使用vb.net在gridview中编写更新代码我得到了错误 [英] How to write the update code in gridview using vb.net And I got Error

查看:87
本文介绍了如何使用vb.net在gridview中编写更新代码我得到了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面插入了错误行代码:



Sql =更新详情设置Deptartment ='& txtDept.Text& ',tenthMark ='& txtten.Text& ',zthMark ='& txttwel.Text& ',Maths ='& txtmaths.Text& ',Physics ='& txtphy.Text& ',Chemistry ='& txtche.Text& '姓名='& txtName.Text& '







但是我得到了错误:



异常详细信息: System.NullReferenceException:对象引用未设置为对象的实例。





请给我任何帮助







谢谢,

I inserted the error line code in below:

Sql = "Update details set Deptartment= '" & txtDept.Text & "', tenthMark= '" & txtten.Text & "', zthMark= '" & txttwel.Text & "', Maths= '" & txtmaths.Text & "', Physics= '" & txtphy.Text & "', Chemistry= '" & txtche.Text & "' where Name= '" & txtName.Text & "'"



But I got Error this:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.


Please any one help to me



Thank You,

推荐答案

SQL字段名称不能以数字开头,例如10thMark等。

你应该重建您的SQL查询以使用参数化查询以避免 sql注入。 [ ^ ]

了解更多: VB.NET& System.Data.Odbc - 参数查询(OdbcParameter) [ ^ ]
SQL field name cannot starts with number, e.g 10thMark etc.
You should reconstruct your sql query to use parameterized query to avoid sql injection.[^]
Read more: VB.NET & System.Data.Odbc - Parameter Query (OdbcParameter)[^]


这篇关于如何使用vb.net在gridview中编写更新代码我得到了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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