Delete Command
Add a Button control to the Web Forms page and paste the following code.
Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Delete.Click Try myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\sandeep\books.mdb;") myConn.Open() myComm = New OleDbCommand("Delete from Table1 where isbn=192435211", myConn) Dim sa As Integer = myComm.ExecuteNonQuery() Response.Write("Records deleted" & " " & sa) Catch End Try End Sub | ||||
System.Data.SqlClient The System.Data.SqlClient namespace provides classes that are required to connect to SQL Server. Let's take a look at the classes provided by System.Data.SqlClient. SqlConnection Class The SqlConnection class represents a connection to SQL Server data source. SqlCommand Class The SqlCommand class represents a SQL statement or stored procedure for use in a database with SQL Server. SqlDataReader The SqlDataReader class creates a data reader to be used with SQL Server. SqlDataAdapter The SqlDataAdapter class represents a bridge between the dataset and the SQL Server database. It includes the Select, Insert, Delete and Update commands for loading and updating the data. Code Samples The following code samples will put the System.Data.SqlClient namespace and the classes within it to work. Select Command Open a new Web Forms page, add a Button to it and paste the following code. The following code will display data from Discounts table in Pubs sample database.
Insert Command Add a Button control to the Web Forms page and paste the following code. The following code will insert a record into the Jobs table in Pubs sample database.
Delete Command Add a Button to the Web Forms page and paste the following code. The following code will delete a record from the Authors table in Pubs sample database.
Update Command Add a Button to the Web Forms page and paste the following code. The following code will update a record in Authors table.
|
No comments:
Post a Comment