0

please help me. this is a uni project and I keep getting the error "Conversion from string "" to type 'Double' is not valid." even when I made sure that everything is in the correct type, everything with a value...etc.

I want to insert some new rows in my access database, here is a picture of the table that Im trying to insert into enter image description here

and this is the code the error appears at the select statement in the sub w()

Dim c As Integer
    Dim b As Double
    Dim a, d, z As String
    a = "'" + TextBox1.Text + "'"
    b = CInt(TextBox2.Text)
    c = CInt(TextBox3.Text)
    d = "'" + TextBox4.Text + "'"
    z = "'" + ComboBox1.SelectedItem + "'"


    If ComboBox1.SelectedItem = "الجبيل" Then
        w("insert into employees (em_id,em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12303 + "," + z + "," + c + "," + b + "," + d + ")")
    ElseIf ComboBox1.SelectedItem = "جدة" Then
        w("insert into employees (em_id,em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12302 + "," + z + "," + c + "," + b + "," + d + ")")
    ElseIf ComboBox1.SelectedItem = "الرياض" Then
        w("insert into employees (em_id, em_name,m_id,city,phone,salary,password)" & " values (" + 32111 + "," + a + "," + 12301 + "," + z + "," + c + "," + b + "," + d + ")")
    End If
    MsgBox("تم إضافة السجل بنجاح")
    TextBox1.Clear()
    TextBox2.Clear()
    TextBox3.Clear()
    TextBox4.Clear()

the sub w("") is:

 Public Sub w(ByVal s As String)
    Dim cum As New OleDbCommand(s, con)
    cum.ExecuteNonQuery()
End Sub

problem is that it works on different forms (to diffident tables and stuff), but not in here...

what should I do?

Community
  • 1
  • 1
shohoud
  • 27
  • 9

0 Answers0