D
Dino M. Buljubasic
How do I insert a NULL value inside an INSERT statement in an SQL Server
database?
Thank you,
Dino
database?
Thank you,
Dino
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Scott M. said:You could use a variable that has been set to = DBNull.Value in the
statement.
Miha Markic said:Hi Dino,
Either use parametrized query and pass DBNull.Value as parameter value or
use a sql statement like:
insert into mytable (field1) values (null);
Dino M. Buljubasic said:Hi Miha,
Using 'null' inside INSERT is not supported anymore. I get error to
use System.DBNull.Value instead but that one inserts an empty string
instead of <NULL>.
Dino M. Buljubasic said:Hi,
thank you for your reply. The code looks like:
INSERT INTO tblTable(fldField) VALUES(Iif(cboCombo.Enabled,
cboCombo.SelectedItem, DBNull.Value))
Dino M. Buljubasic said:Hi,
thank you for your reply. The code looks like:
INSERT INTO tblTable(fldField) VALUES(Iif(cboCombo.Enabled,
cboCombo.SelectedItem, DBNull.Value))
, the fldField is Varchar(10), it allows nulls.
Thank you,
Dino
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.