I have a combobox that is connected to a column in a access database, I would like to put a null value in the field of the column's database if my combobox value is empty. I wrote this code and I know that is wrong but I can't figure it out.
myvalue is declared as integer
Dim myConnectionString As SqlConnection = New SqlConnection("Data Source=*****\****;Initial Catalog=****;user=***;password=****")
Dim myCommand As String
Dim cmd As SqlCommand
Dim myvalue As Integer
If IsDBNull(Form1.CBEsp2.SelectedValue) Then
myvalue = vbNull
Else
myvalue = Form1.CBEsp2.SelectedValue
End If
MsgBox(Form1.CBEsp2.SelectedValue)
myCommand = "UPDATE DoctorEnterpriseDetails SET " & _
"RankId = " & Form1.CBSelec.SelectedValue & ", " & _
"GroupId = " & Form1.CBCateg.SelectedValue & ", " & _
"PrescribingPotential = " & Form1.CBPP.SelectedValue & ", " & _
"Observation = '" & Form1.TxtObs2.Text & "', " & _
"Telephone = '" & Convert_Null(Form1.TxtTelefone.Text, "") & "', " & _
"Mobile = '" & Convert_Null(Form1.TxtTelem.Text, "") & "', " & _
"Speciality1 = " & Form1.CBEsp1.SelectedValue & ", " & _
"Speciality2 = " & myvalue & " " & _
"WHERE EnterpriseId = 26 AND DoctorId = " & Form1.labelvazia.Text
MsgBox(myCommand)
cmd = New SqlCommand(myCommand, myConnectionString)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Thanks.