Hi,
I have the following SQL on my dataset (trainingloc.xsd)
Code:
SELECT - 1 AS LocationID, '--Please Select--' AS TrainingLoc
UNION ALL
SELECT LocationID, TrainingLoc
FROM tblTrainingLocType
ORDER BY LocationID
Now, on Form Load,
I have
Training Location (combobox)
--Please Select--
Location A
Location B
Location C
Now, there is an insert statement when to enter fields as below;
Code:
Try
Using sqlConn As SqlConnection = GetDbConnection()
Using sqlCmnd As New SqlCommand("INSERT INTO dbo.tblCustomer (TrainingLocation, Notes) Values ( @TrainingLocation, @Notes)", sqlConn)
With sqlCmnd.Parameters
.AddWithValue("@TrainingLocation", IIf(cmbtrainloc.Text.Length > 0, cmbtrainloc.Text, DBNull.Value))
.AddWithValue("@Notes", IIf(txtnotes.Text.Length > 0, txtnotes.Text, DBNull.Value))
End With
sqlCmnd.ExecuteNonQuery()
sqlConn.Close()
End Using
End Using
The issue is - when it is the --Please Select--, I would like to enter NOTHING to the database. At present, it enters and saves --Please Select--
Please note; this field does allow NULL values, in other occassions the location cited might not be in the combo box list.
Thank you