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

Stored Procedures

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I have a stored procedure that lets me pass in a null value.

However in my VB code the value is an integer and will not let me put a null value in it.

For example

How do I pass a null value into the stored procedure if the user does not enter a number in a text box.

Please keep answers simple as I am new to this.
 
(Your title is very generic, so you may get limited responses, but I'll give it a try.)

Pass the word NULL in your parameter string for the stored procedure, e.g., "exec MyProc 'Hello','World',27,NULL"
To find out if you need to do this, then check the value of the text box:
Code:
If len(trim$(txtFoo.text)) = 0 Then
    sFoo = "Null"
 Else
    sFoo = txtFoo.text
 End If
[alternatively:
Code:
sFoo = iif(len(trim$(txtFoo)) = 0,"Null",txtFoo.text)
]

sSQL = "Exec MyProc " & .....
sSQL = sSQL & ", " & sFoo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top