how to insert a value in vb.net with example
how to insert a value in vb.net with example
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Aug 31, 2012, 7:32 AM
Private strConnString As String = ConfigurationManager.ConnectionStrings("MyConsString").ConnectionString
Private str As String
Private cmd As SqlCommand
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim con As New SqlConnection(strConnString)
con.Open()
str = "INSERT INTO test VALUES (@amount, @description)"
cmd = New SqlCommand(str, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@amount", Convert.ToInt64(txt_amount.Text))
cmd.Parameters.AddWithValue("@description", rtxt_description.Text)
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
Response.Write("Records Inserted")
End Sub
Thanks