Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assign null values to a variable 1

Status
Not open for further replies.

logi2000

Programmer
Jun 17, 2003
221
CR
is it possible to assign a null value to a integer, string or datetime variable ?

so when i send the data to the database it stores a null, and not any default number assign to the variable when it is declared.
 
The way I would do this is to use the parameters collection of the command object.

Code:
cmd.parameters(0).value = dbnull.value
if you can't/don't use parameters (eg dynamically generated SQL), then you'll have to figure out some way of using the SQL keyword NULL instead of the value of the variable

eg

Code:
strNumber = iif(txtBox1.text = "", "null", txtBox1.text)

strSQL = "update MyTable set MyField = " & strNumber & " where ID = " & intID.tostring
Hope this helps

Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top