title: Insert,update and delete data from Sql database using vb.net?
body: <p>This is my code for inserting data in the data table. When <code>Execute</code> i m getting the message "SUCCESS". But the data is not present in the data table.</p>
  
  <pre><code>Imports System.Data
  Imports System.Data.SqlClient
  
  Partial Public Class _Default
      Inherits System.Web.UI.Page
      Dim s As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=G:\ANDY\Dot Net.Practical\SQL DATA BASE\inserting4\inserting4\App_Data\location.mdf;Integrated Security=True;User Instance=True"
      Dim sql As String
      Dim con As New SqlConnection
      Dim cmd As SqlCommand
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
          con = New SqlConnection(s)
          con.Open()
  
      End Sub
  
      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  
          sql = "insert into location(name,street,city)values(@name,@street,@city)"
          cmd = New SqlCommand(sql, con)
  
          cmd.Parameters.Add("@name", SqlDbType.NVarChar).Value = TextBox1.Text
          cmd.Parameters.Add("@street", SqlDbType.NVarChar).Value = TextBox2.Text
          cmd.Parameters.Add("@city", SqlDbType.NVarChar).Value = TextBox3.Text
          cmd.ExecuteNonQuery()
  
          MsgBox("SUCCESS")
  
  
      End Sub
  End Class
  </code></pre>