Ado Net
Ado Net
MAKING CONNECTION TO
THE DATABASE
Open a connection to the database.
Dim strConnection As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& "C:\Program Files\Microsoft
Office\Office\Samples\Northwind.mdb
Dim cn As OleDbConnection = New
OleDbConnection(strConnection) cn.Open( )
IMPORT
Import system.data
Import system.data.sqlclient
METHOD
Code
Dim a As String = "Data Source=C:\Users\Prince
raj\Documents\Visual Studio
2010\Projects\rups\rups\qwert.mdf"
Dim cn As SqlConnection = New SqlConnection(a)
cn.Open()
INSERT
This is used to insert data in the table or you can say the row and
columns of the database.
Adding a new row to a table in a DataSet is a three-step process:
1. Use the DataTable class's NewRow method to create a new
DataRow.
2. Set the values of the columns in the row.
3. Add the new row to the table.
For example, assuming that dt is a DataTable object, and that the
table has columns named name" and age", this code adds a new row
to the table:
' Add a row.
SELECT
Select command is used to perform query in the
database.
' Create a data adapter object and set its SELECT
command.
Creating a string object
UPDATE
Update command is used to modify the value of
RECORDS of the table
' Update the database.
da.Update(ds, PERSON")
DELETE
Delete command is used to delete a particular
RECORD from the table.
Delete a record.
cn.Close( )