Just don’t assign anything to that field. If the field is not included in the insert, it will be set to NULL (unless you set it to not null with a default value in the database).
First of all I would like to say the best (and save) way to insert or update a MySQL column with NULL (or any) values is using the MySQLPreparedStatement, as follow:
This example shows how to insert “ABCD” and 20 values in a table:
Dim ps As PreparedSQLStatement
Dim mDB As New MySQLCommunityServer
db.Host = “127.0.0.0”
db.Username = “admin”
db.Password = “admin”
’ Write here your Database connection code.
ps = mDB.Prepare(“INSERT INTO TABLENAME (Column1, Column2) VALUES (?, ?)”)
And now, if you want to insert expressly NULL value, for example, in Column2, instead of value 20, replace line 11 ps.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_LONG)
with this other: ps.BindType(1, MySQLPreparedStatement.MYSQL_TYPE_NULL)
Then simply skip line 13,( not assign any value to column) and all will work ok.
This method insert a NULL value in Column2, instead of any integer value. (of course, column definition has to allow NULL values)
Use the same for update sentences.