本文介绍了MySql DB更新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一点问题。



当我尝试将数据输入表格时,我在mysql数据库中编写程序,我收到此警告。当数据库数据部分为NULL时,我收到此错误。问题不会返回空。

Hi. I have a little problem.

I wrote programs in mysql database when I try to enter data into a table, I get this warning. I get this error when the database data section is NULL. The problem does not return empty.

Quote:



错误:DBNull类型和对于字符串'='运算符未定义


Error: DBNull type and for the string '=' operator is not defined

我的更新代码:

my update code:

Dim Table As String = ini.ReadValue("COMM", "DBTable")
Dim Data As String = "CODE_NO='" + DataGridView1.Item(0, i).Value.ToString
Dim con As New MySqlConnection
Dim Comm As New MySqlCommand

Comm = New MySqlCommand("UPDATE " + Table + " SETKAY='" + Label4.Text + "'" + ", STATUS='Waiting', DATE='" + DateTime.Now.ToString + "'" + " WHERE " + Data + "'", con)



数据库表格单元状态=(NULL)(不工作)


Database Table cell status= (NULL) ( not working )

<br />
Database Table cell status= " "

(工作)







谢谢大家。但不明白每个解决方案。我想告诉你的照片。

[]

[]

( Working )



Thanks everyone. But dont understand every solution. I want to tell with your pictures.
http://tinypic.com/view.php?pic=2ljhqwk&s=8#.VFaaw01yZ9A[^]
http://tinypic.com/view.php?pic=wircd5&s=8#.VFaa3U1yZ9A[^]

推荐答案


Dim Data As String = "IFNULL(CODE_NO,'')=@Item"





另请参考]


Dim Query As String = "Update YourDB.my_table_name SET Value1=@V1, Value2=@V2 Where Value3=@Condition;"
Parameters.AddWithValue("@V1", "Value Of 1")
Parameters.AddWithValue("@V2", "Value Of 2")
Parameters.AddWithValue("@Condition", 0)





然后Executenonquery()启动你的命令行动。



你可以看到关于MySQL的进一步解释,我也回答了。我希望它能帮助你开始朝着正确的方向前进。但在进一步研究之前,你将不得不做一些研究和研究基础知识。



Then Executenonquery() to initiate your action on your command.

You can see further explanation on MySQL covered in this Answer, also answered by me. I hope it helps get you started in the right direction. But you are going to have to do some research and study the basics before going further with this.


这篇关于MySql DB更新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 13:26