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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Nulls to SQL Server

Status
Not open for further replies.

jerstep

Technical User
Mar 22, 2002
18
0
0
AT
Hello.

I have a SQL Server 2000 DB. A field in a table allows "Nulls" but has no default value.

Using VB 6.0, I've written a procedure to add records to the table.

Question. How do I pass a Null 'value' to SQL Server ?

Do I have to set a default value for the field of 'Null' ? If so, how ?

Or can I do something like :

if textbox1.text = "" then VarToPassToSQL = NULL endif ?

Anyone any ideas ?
Thanks
J.



 
you might try using the vbNullString string constand
Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
jerstep -

In your update sql, set the value to null.
Code:
sSQL = ""
sSQL = sSQL & " UPDATE tbl_Users"
sSQL = sSQL & " SET LastName = NULL"
sSQL = sSQL & " WHERE UserName = 'blah'"

The vbNullString is not a database NULL at all, but simply a empty string useful in passing to DLLs written in C.

You may also want to take a look at thread796-248117

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top