NULLS values and text box values

  • Thread starter Thread starter Craig
  • Start date Start date
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
 
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)
 
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.
 
Back
Top