Reputation: 420
Is there way to insert null into mysql from an empty text field in vb.net
thanks..
Upvotes: 0
Views: 4827
Reputation: 53
If this is not working, please check whether the field is null allowed.
Using cmd As New OleDb.OleDbCommand()
//... set connection string etc
cmd.Parameters.Add("myFieldName", OleDbType.VarWChar)
cmd.Parameters("myFieldName").Value = DBNull.Value
//... etc
End Using
Upvotes: 0
Reputation: 131
Simply you may use the following as your query string:
Dim Query as String = "Update Table set Column = NULL Where ID = " & SomeTextBox.Text
You apply that also when you insert.
Upvotes: 0
Reputation: 16043
Assuming you are using ADO.NET, OleDb and parameters, you need to set the value to DBNull.Value
Example:
Using cmd As New OleDb.OleDbCommand()
//... set connection string etc
cmd.Parameters.Add("myFieldName", OleDbType.VarWChar)
cmd.Parameters("myFieldName").Value = DBNull.Value
//... etc
End Using
Upvotes: 2