Hi all, again...
I have an interesting one (well I think it is interesting).
I have a form with a binding source on it.
If I change one of the bound fields which is an integer - to have a value of blank, through the use of a textbox then the program stops working.
If I change a text field it works fine.
The sql database definition for this field is Integer, and allows NULL.
The fields in question are vehicle year, vehicle tare, vehicle gvm, vehicle gcm, vehicle mtm, vehicle, axles, and vehicle wheelbase.
If I change the value of these fields to be blank, and click on Save, absolutely nothing happens, and I have to stop the program via Visual Studio....My File--> Exit button does not work either.
Below is the code for doing the update
Any ideas would be appreaciated
I have an interesting one (well I think it is interesting).
I have a form with a binding source on it.
If I change one of the bound fields which is an integer - to have a value of blank, through the use of a textbox then the program stops working.
If I change a text field it works fine.
The sql database definition for this field is Integer, and allows NULL.
The fields in question are vehicle year, vehicle tare, vehicle gvm, vehicle gcm, vehicle mtm, vehicle, axles, and vehicle wheelbase.
If I change the value of these fields to be blank, and click on Save, absolutely nothing happens, and I have to stop the program via Visual Studio....My File--> Exit button does not work either.
Below is the code for doing the update
VB.NET:
Private Sub cmdVehSave_Click(sender As Object, e As EventArgs) Handles cmdVehSave.Click
'Variables for handling string to integer values in the database
Dim intVehJobNo As Integer?
Dim intVehYear As Integer?
Dim intVehtare As Integer?
Dim intvehgvm As Integer?
Dim intvehgcm As Integer?
Dim intvehmtm As Integer?
Dim intvehaxles As Integer?
Dim intvehwheelbase As Integer?
intVehJobNo = txtjdJobNo.Text
If txtVehYear.Text = "" Then intVehYear = Nothing Else intVehYear = txtVehYear.Text
If txtVehTare.Text = "" Then intVehtare = Nothing Else intVehtare = txtVehTare.Text
If txtVehGvm.Text = "" Then intvehgvm = Nothing Else intvehgvm = txtVehGvm.Text
If txtVehGcm.Text = "" Then intvehgcm = Nothing Else intvehgcm = txtVehGcm.Text
If txtVehMtm.Text = "" Then intvehmtm = Nothing Else intvehmtm = txtVehMtm.Text
If txtVehAxles.Text = "" Then intvehaxles = Nothing Else intvehaxles = txtVehAxles.Text
If txtVehWheelbase.Text = "" Then intvehwheelbase = Nothing Else intvehwheelbase = txtVehWheelbase.Text
Dim strVehUpdate As String = "UPDATE VEHICLE " &
"SET veh_job_no = " & intVehJobNo & ", Vehicle_Year = " & intVehYear & ", Vehicle_Make = '" & txtVehMake.Text & "', Vehicle_Model = '" & txtVehModel.Text & "', Vehicle_Rego = '" & txtVehRego.Text & "', Vehicle_vin = '" & txtVehVin.Text & "', " &
" vehicle_chassis = '" & txtVehChassis.Text & "', vehicle_type = '" & txtVehType.Text & "', " &
" vehicle_tare = " & intVehtare & ", vehicle_gvm = " & intvehgvm & ", vehicle_gcm = " & intvehgcm & ", vehicle_mtm = " & intvehmtm & ", vehicle_axles = " & intvehaxles & ", " &
" vehicle_wheelbase = " & intvehwheelbase & ", vehicle_bodytype = '" & txtVehBodyType.Text & "', vehicle_condition = '" & txtVehCondition.Text & "', vehicle_class = '" & txtVehClass.Text & "', vehicle_notes = '" & txtVehNotes.Text & "' " &
" WHERE veh_job_no = '" & intVehJobNo & "'"
If sql.DataUpdate(strVehUpdate) = 0 Then
MsgBox("Job not found")
Else
MsgBox("Job Updated")
End If
End Sub
Any ideas would be appreaciated