如何使用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)[^]