please people your help will be appreciated.
i have a table with data definition:
column Datatype
BookID int
AuthorFirstname nvarchar(20)
AuthorSecondName nvarchar(20)
BookTitle nvarchar(50)
Price nvarchar(50)
My problem is that i can't see the inserted data in my table
Below is the whole code:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.Exception
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Dim connection As SqlConnection = Nothing
Dim conn As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Libridata.mdf;Integrated Security=True;User Instance=True"
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim firstname As String = txtbx1.Text
Dim secname As String = txtbx2.Text
Dim title As String = txtbx3.Text
Dim price As String = txtbx4.Text
Dim Idd As Integer = txtbx5.Text
Try
Dim conn As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Libridata.mdf;Integrated Security=True;User Instance=True"
connection = New SqlConnection(conn)
connection.Open()
Dim sql As String = "INSERT INTO Libritable( BookID,AuthorFirstname,AuthorSecondName,BookTitle,Price) VALUES (@BookID,@AuthorFirstname, @AuthorSecondName, @BookTitle, @Price)"
Dim cmd As SqlCommand = New SqlCommand(sql, connection)
cmd.Parameters.AddWithValue("@AuthorFirstname", firstname)
cmd.Parameters.AddWithValue("@AuthorSecondName", secname)
cmd.Parameters.AddWithValue("@BookTitle", title)
cmd.Parameters.AddWithValue("@Price", price)
cmd.Parameters.AddWithValue("@BookID", Idd)
cmd.ExecuteNonQuery()
MessageBox.Show("book added successfully!")
Catch ae As SqlException
MessageBox.Show(ae.Message.ToString())
End Try
End Sub
End Class