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 by Val

Val
Thu Mar 31 19:49:44 CST 2005

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



"gv" <viatorg@musc.edu> wrote in message
news:ecHYEFjNFHA.244@TK2MSFTNGP12.phx.gbl...
> 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 by gv

gv
Fri Apr 01 09:42:14 CST 2005

thks

GV




"Val Mazur (MVP)" <group51a@hotmail.com> wrote in message
news:OvBaW0lNFHA.3492@TK2MSFTNGP09.phx.gbl...
> 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
>
>
>
> "gv" <viatorg@musc.edu> wrote in message
> news:ecHYEFjNFHA.244@TK2MSFTNGP12.phx.gbl...
>> 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
>>
>
>