Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

Insert data in Sql Table Visual basic 2012

$
0
0

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


Viewing all articles
Browse latest Browse all 15264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>