How to pass the item from a combobox to a table in sql server 2012

0

I am new to visual and I have a problem when passing a textbox to a table in sql server 2012, it does it correctly, but when sending the content that I select from a combobox, it does not load anything in the database. data, I am sending the data in this way:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

comando.CommandText = "insert into equipos (
  placa, fechaDeIngreso, tipoDePc, referencia, tipoDeMntto, 
  estadoFinal, fechaDeSalida, responsable, observaciones ) 
  values ('" & TextBox1.Text & "', '" & TextBox2.Text & "', '" & 
    TextBox4.Text & "', '" & TextBox3.Text & "', '" & 
    TextBox5.Text & "', '" & TextBox7.Text & "', '" & 
    TextBox8.Text & "', '" & TextBox9.Text & "', '" & 
    TextBox6.Text & "', '" & ComboBox1.Text & "' 
  )"

comando.ExecuteNonQuery()

 End Sub
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        conexion.ConnectionString = "Data Source=DESKTOP-6FH5UOF\SQLEXPRESS2017;Initial Catalog=electronica;Integrated Security=True"
        conexion.Open()
        comando.Connection = conexion

>equiposDT.Columns.Add("Placa")
        equiposDT.Columns.Add("fechaDeingreso")
        equiposDT.Columns.Add("tipoDePc")
        equiposDT.Columns.Add("referencia")
        equiposDT.Columns.Add("tipoDeMntto")
        equiposDT.Columns.Add("estadoFinal")
        equiposDT.Columns.Add("fechaDeSalida")
        equiposDT.Columns.Add("responsable")
        equiposDT.Columns.Add("observaciones")
        equiposDT.Columns.Add("item")

 End Sub

In that way I take the data from the textbox and the combobox, to be sent to the sql, now when I check my database all the values of the textbox appear, but in the combobox column I get the NULL word, in all columns I have varchar type variables (50). I do not know why it does not save the value.

Thank you, and I apologize for the way you ask the question.

    
asked by Anderson R 03.08.2017 в 03:49
source

0 answers