I am sending values to my database from textboxes that are usualy all required texboxes. In one case I have a textbox that is optional but my Insert Into String looks something like the one listed below. The database requires that if there is no value in the textbox the field must be a null. How can I send a Null Value to my sql server in the cases that I need to do so?
I know that I could use an IF then along with two seperate Insert Strings but I am thinking there is probably a better way/VB Code:
With cmd .CommandText = "Insert Into TimeGR (" & _ "EntryPerson, " & _ "Job," & _ "JobName," & _ "WeekEnding," & _ "Employee," & _ "FirstName," & _ "LastName," & _ "RateTime," & _ ") Values('" & _ strEntryPerson & "','" & _ strJobNumber & "','" & _ strJobName & "','" & _ strWeekEnd & "','" & _ strEmp & "','" & _ strFname & "','" & _ strLname & "','" & _ strTime & "','" & _ ")" .ExecuteNonQuery() trn.Commit() End With




Reply With Quote