473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

MySQL: Insert null values?

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

Thanks in advance!
Nov 20 '05 #1
2 4347
"hellrazor" <jo***@another-world.com> schrieb

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


"...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

Nov 20 '05 #2
"Armin Zingler" <az*******@freenet.de> wrote in
news:40***********************@news.freenet.de:
"hellrazor" <jo***@another-world.com> schrieb

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

Thanks. I figured it out right after I posted this. MySql takes care of
it.
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

right.

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.


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Davenport | last post by:
Hi, Here's my question: How do I pass a NULL value in a variable to a MySQL DB? Here's an overview of my problem: I have a PHP page that processes code, then inserts the code into a database....
1
by: Marcus | last post by:
Hello, quick question about MySQL storing NULL values... Say I have a textbox called $_POST and a variable $var. if(empty($_POST)) $var = NULL; else $var = $_POST; Disregarding...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
3
by: Rodrigo C. Souza | last post by:
I need to insert a null value in a table on MS SQL Server 2000 using a stored procedure. When I send no data to the stored procedure, I get an error saying that the value cannot be null, but I did...
2
by: hellrazor | last post by:
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...
8
by: whocracks | last post by:
hi... can you tel me how to insert null values in Access table using Vb code.... actually i want to store record having some fields with null values...plz....... i mean error is in query...
2
by: teddysnips | last post by:
I have an application that does some data manipulation of some tables to format a table for a report. 1. First I open the table that gives me the parameters for some later queries strSQL =...
1
by: praveena mani | last post by:
Can we insert null values in stored procedures? When we tried to insert null inprocedures its giving query ok... But wen we try to display the values from table it shows empty set... Y???
3
by: rc | last post by:
How to insert NULL values in to int field using params. I'm trying to use pymssql.execute, passing the operation and list of params. One of the values in the params is a NULL value going to int...
1
by: Bigdaddrock | last post by:
I am attempting to concatenate LName and FName into an expression I will call TelName. If there is no LName, I would like to just have FName appear. If there is no FName I would like just LName to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.