Set your logic to assign
.... .Value = DBNULL.Value
when the TextBox is a null string.
See my article "Much ADO about Nothing"
http://www.betav.com/msdn_magazine.htm
for more info about nothing (and NULLs)
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"tshad" <(E-Mail Removed)> wrote in message
news:%23w2QKuN%(E-Mail Removed)...
>I am trying to update field and if nothing is in the .text field, I get an
>error.
>
> For example, if I have the following string:
>
> Dim CommandText as String = "Update ftsolutions.dbo.Applicant set
> salaryCurrent = @SalaryCurrent where applicantID = @applicantID"
>
> with the following parameter:
>
> .Add("@salaryCurrent",SqlDbType.Money).value = salaryCurrent.text
>
> I will get an error if salaryCurrent.text has nothing in it.
>
> I want to make the field null, if nothing is entered. Something like:
>
> if salaryCurrent.text = ""
> .Add("@salaryCurrent",SqlDbType.Money).value = Nthing
> else
> .Add("@salaryCurrent",SqlDbType.Money).value = salaryCurrent.text
> end if
>
> This doesn't work, but how would I make it work?
>
> Thanks,
>
> Tom.
>