i have a windows forms with 7 texboxes, i would like to save the input into a sqwl databse , but i am having a bit of problem, this is my code:

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

    Dim con As New SqlConnection("server = GX520B\SQLEXPRESS;Initial Catalog=return;Integrated Security=True")

    Dim cmd As New SqlCommand("insert into dbo.RMA (Rma_Number,Vendor,Device,Serial_Number,Model,Problem,Date) values (@Rma_Number,@Vendor,@Device,@Serial_Number,@Model,@Problem,@Date)")
    cmd.Connection = con
    con.Open()
    cmd.Parameters.AddWithValue("@Rma_number", Me.TxtRMA.Text)
    cmd.Parameters.AddWithValue("@Vendor", Me.TxtVendor.Text)
    cmd.Parameters.AddWithValue("@Device", Me.TxtDevice.Text)
    cmd.Parameters.AddWithValue("@Serial_Number", Me.TxtSN.Text)
    cmd.Parameters.AddWithValue("@Model", Me.TxtModel.Text)
    cmd.Parameters.AddWithValue("@Problem", Me.TxtProblem.Text)
    cmd.Parameters.AddWithValue("@Date", Me.TxtDate.Text)

    Dim reader As SqlDataReader = Nothing


    cmd.ExecuteNonQuery()

    con.Close()

end sub
i am getting the error:
Invalid column name serial_number

AndreRet commented: Please move to vb.net thanx +12

Sorry for the obvious, but are you sure the field is called "Serial_Number"?

Instead of using parameters try it with the text boxes it self....

Dim cmd As New SqlCommand("insert into dbo.RMA values ('"+TxtRMA.Text+"','"+TxtVendor.Text+"','"+TxtDevice.Text+"','"+TxtSN.Text+"','"+TxtModel.Text+"','"+TxtProblem.Text+"','"+TxtDate.Text+"')")
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim dr As SqlDataReader

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

    con.Open()
    cmd.Parameters.AddWithValue("@Name", Me.txtName.Text)
    cmd.Parameters.AddWithValue("@Phone", Me.txtPhone.Text)
    Dim reader As SqlDataReader = Nothing
    cmd.ExecuteNonQuery()
    con.Close()
    MsgBox("Detail sucussfully Added")

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    con = New SqlConnection("Server=ALAN-PC\SQLEXPRESS;Database=EarnestBank;Integrated Security=SSPI;")
    cmd = New SqlCommand("insert into Contact_Manager (Name,Phone) values (@Name,@Phone)")


    cmd.Connection = con

con = New SqlConnection("Server=ALAN-PC\SQLEXPRESS;Database=EarnestBank;Integrated Security=SSPI;")

        cmd = New SqlCommand("select MemberId from Contact_Manager ", con)
        con.Open()
        dr = cmd.ExecuteReader

        If (dr.HasRows) Then
            While dr.Read
                'MsgBox(dr.GetInt32(0))
                cb1.Items.Add(dr.GetInt32(0))
            End While
        Else
            MsgBox("No rows found.")
        End If
        dr.Close()


        con.Close()
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try




End Sub

Private Sub cb1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb1.SelectedValueChanged
    con = New SqlConnection("Server=ALAN-PC\SQLEXPRESS;Database=EarnestBank;Integrated Security=SSPI;")
    cmd = New SqlCommand("select Name,Phone from Contact_Manager where MemberId=@val", con)
    cmd.Parameters.Add("@val", SqlDbType.Char, 6).Value = cb1.SelectedItem

    con.Open()
    dr = cmd.ExecuteReader
    While dr.Read
        txt1.Text = dr.GetString(0)
        txt2.Text = dr.GetString(1)
        'txt3.Text = Convert.ToString(dr.GetSqlMoney(2))
    End While
    con.Close()
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.