all groups > dotnet ado.net > march 2005 >
You're in the

dotnet ado.net

group:

sqlcommand parameters with null


sqlcommand parameters with null gv
3/31/2005 3:36:07 PM
dotnet ado.net:
Is there an easier \ shorter way of doing this?

If txtreason.Text = "" Then
NoteCmd.Parameters.Add("@reason", SqlDbType.VarChar, 100).Value
= vbNull
Else
NoteCmd.Parameters.Add("@reason", SqlDbType.VarChar, 100).Value
= txtreason.Text
End If

thanks
gv

Re: sqlcommand parameters with null Val Mazur (MVP)
3/31/2005 8:49:44 PM
You could do it next way

NoteCmd.Parameters.Add("@reason", SqlDbType.VarChar, 100).Value = _
IIf(txtreason.Text = "", DBNull.Value, txtreason.Text)

--
Val Mazur
Microsoft MVP

http://xport.mvps.org



[quoted text, click to view]

Re: sqlcommand parameters with null gv
4/1/2005 10:42:14 AM
thks

GV




[quoted text, click to view]

AddThis Social Bookmark Button