none
Insert data in Sql Table Visual basic 2012

    Question

  • I am having a problem, someone help me out please:

    Public Class Form1

        Dim conn As System.Data.SqlClient.SqlConnection
        Dim cmd As System.Data.SqlClient.SqlCommand
        Dim dr As System.Data.SqlClient.SqlDataReader
        Dim sqlStr As String

        Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
           

    conn = New SqlClient.SqlConnection("Data Source=(localdb)\projects;Initial Catalog=Newdb;Integrated Security=True")

            conn.Open()

            sqlStr = "INSERT INTO Table([Menu],[Type Of Menu],[Price],[Quantity]) VALUES('" & txtMenu.Text & "', '" & txtTypeMenu.Text & "', '" & txtPrice.Text & "', '" & txtQuantity.Text & "')"

            cmd = New SqlClient.SqlCommand(sqlStr, conn)
            cmd.ExecuteNonQuery()
            conn.Close()
        End Sub
    End Class

    Tuesday, November 19, 2013 7:10 PM

Answers

All replies