0% found this document useful (0 votes)
67 views

Ado Net

ADO.NET is used to connect and interact with databases. It allows opening a connection, inserting, selecting, updating, and deleting data. Common tasks include creating a connection string, executing commands like SELECT, and using a data adapter to fill a dataset and update changes back to the database.

Uploaded by

PrinceRajDKiler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Ado Net

ADO.NET is used to connect and interact with databases. It allows opening a connection, inserting, selecting, updating, and deleting data. Common tasks include creating a connection string, executing commands like SELECT, and using a data adapter to fill a dataset and update changes back to the database.

Uploaded by

PrinceRajDKiler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

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

Dim strSelect As String = "SELECT *


FROM person"
CREATING A ADAPTER OBJECT AND PUTTING VALUE
OF 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 SYNTAX


'

Delete a record.

row = dt.Select("CategoryName = 'MyCategory'")


row.Delete( )

WRITING THE DATA BACK TO


THE DATABASE
da.Update(ds, PERSON")
' Close the database connection.

cn.Close( )

You might also like