How to insert a value in vb.net with example
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Aug 31, 2012, 3:32 AM EDT
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