NULLS values and text box values

C

Craig

I have a text box on a web form that a user enters a number in.

If they blank out the text box then I want to put a null value back into the
database field.

I want to return the value to NULL like txtWaterDischargeRate =
System.DBNull.Value instead of Nothing but I get an error

Can't convert NULL to integer

How can I enter a null in the database field on MS SQL Server?

Thanks
 
C

Craig

Sample code......

With DataSetLocationsForm1.tblLocations(0)
.WaterDischargeCost = txtWaterDischargeCost.Text
.MoreFields = txtOtherTextboxes.Text
End With
SqlDataAdapter1.Update(DataSetLocationsForm1)

The WaterDischargeCost field in the database is an type real. If they blank
out the text box and click the SAVE button on an existing record I get an
error "Can't convert NULL to integer"

I want to put a null value back into the database field

How do I do this?

Thanks





SqlDataAdapter1.Update(DataSetLocationsForm1)
 
G

Guest

If the column WaterDischargeCost is nullable (minoccurs = 0), then you can use:
DataSetLocationsForm1.tblLocations(0).SetWaterDischargeCostNull()

to let the dataset set the value as null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top