Dear Sir, I wrote code to insert textbox data into sql database, my code working properly but when I open the table no data was added, my code given below, help me...
Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As New SqlDataAdapter
Dim tabl As New DataTable
Dim sql As String
connetionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
connection = New SqlConnection(connetionString)
Try
sql = "insert into model (no,fistname,lastname) values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
adapter.InsertCommand = New SqlCommand(sql, connection)
connection.Open()
adapter.InsertCommand.ExecuteNonQuery()
MsgBox("Row inserted !! ")
connection.Close()
Catch ex As Exception
MsgBox(ex.ToString)
connection.Close()
End Try
End Sub