Groups | Blog | Home
all groups > vb.net > may 2004 >

vb.net : MySQL: Insert null values?


hellrazor
5/18/2004 11:30:00 PM
Hi there,

I have the following INSERT statement:

fieldOne is of type int
fieldTwo is of type date

In MySQL, both are allowed to hold null values.

Now, I try to insert regular data into it:

INSERT INTO myTable (fieldOne,fieldTwo) VALUES(3,'2004-05-18')

NO problem there.

But what is the format for inserting null values?

I tried the following:

nullValue = Nothing

"INSERT INTO myTable (fieldOne,fieldTwo) VALUES(" & nullValue & "," &
nullValue & ")"


I get the following error when I try to submit the query:

ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-4.0.18-max-debug]You have
an error in your SQL syntax. Check the manual that corresponds to your
MySQL server version for the right syntax to use near ',,)' at line 1



hellrazor
5/19/2004 12:29:47 AM
"Armin Zingler" <az.nospam@freenet.de> wrote in
news:40aaa6d8$0$27036$9b622d9e@news.freenet.de:

[quoted text, click to view]


Thanks. I figured it out right after I posted this. MySql takes care of
it.



[quoted text, click to view]


right.


[quoted text, click to view]
Armin Zingler
5/19/2004 2:12:03 AM
"hellrazor" <jorge@another-world.com> schrieb
[quoted text, click to view]

"...VALUES (NULL, NULL)..."

But, this question is neither related to ASP.Net, nor to the VB.Net
language. There's an ADO.Net group: microsoft.public.dotnet.framework.adonet

You should consider using the Parameters property of the Command object you
use to execute the Insert statment. You can assign DBNull.Value to the
Parameter value, and the right SQL string is built by the Command object.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
AddThis Social Bookmark Button