0% found this document useful (0 votes)
19 views8 pages

Practical No 24

GAD

Uploaded by

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

Practical No 24

GAD

Uploaded by

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

Practical No. 24 Understand The Concept Of Ado.Net.

I. Practical Significance:
ActiveX Data Object. NET (ADO.NET) is a set of framework database programming
classes (System. Data namespace) that render the data access services of the .NET
framework.

II. Relevant Program Outcomes (POs)


Basic knowledge: Apply knowledge of basic mathematics, sciences and basic
engineering to solve the computer group related problems.

Discipline knowledge: Apply Computer Programming knowledge to solve the


computer group related problems.

Experiments and practice: Plan to perform experiments and practices to use the
results to solve the computer group related problems.

Engineering tools: Apply relevant Computer programming / technologies and tools


with an understanding of the limitations.

Communication: Communicate effectively in oral and written form.

III. Competency and Practical Skills


This practical expects to develop the following skills in the student.

Develop VB.NET programs to solve computer group related problems.

• Write an NET program for database connection with data Grid view.
• Compile/Debug/Save the „VB.NET‟

IV. Relevant Course Outcomes


Use Data access controls to store data in Database and retrieve it.

V. Practical Outcome
Write a program to fetch data from table and display in Data Grid.

VI. Relevant Affective domain related Outcome(s)

• Follow safety
• Follow ethical

VII. Minimum Theoretical Background


ADO.Net object model is structured process flow through various components.
Architecture of ADO.Net

There are many different types of databases available

• Microsoft SQL Server,


• Microsoft Access,
• Oracle,
• Borland Interbase,
• IBM DB2
• MySQL
Data Provider

Provider name API prefix Data Source Description

Data Sources with an ODBC interface. Normally older data


ODBC Data Provider Odbc bases.

Data Sources that expose an OleDb interface, i.e. Access or


OleDb Data Provider OleDb Excel.

Oracle Data Provider Oracle For Oracle Databases.

SQL Data Provider Sql For interacting with Microsoft SQL Server.

Syntax of Database Connection

Connection
Dim Con As OleDbConnection

Con=New OleDbConnection(“Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C :\


MyDB.accdb;”)

Dim Con as SqlConnection

Con=New SqlConnection(“server=.; user id=sa; password=sa; database=student”)

Command
Dim cmd As OleDbCommand

cmd=New OleDbCommand(“select * from student”, con)

Dim cmd As SqlCommand

cmd=New SqlCommand(“select * from student”,con)

DataReader
Dim dr As OleDbDataReader

Dr=cmd.ExecuteReader
Dim dr As SqlDataReader

Dr=cmd.ExecuteReader

DataSet
Dim dataset As New DataSet()

Da.fill(dataset, “table1”)

DataGrid
DataGridView1.DataSource = ds.Tables(0)

VIII. Resources required (Additional)

• If any web resources required.

IX. Precautions

• Save the program in specific directory /


• Follow safety

X. Resources used (Additional)

• https://www.tutorialspoint.com/vb.net/vb.net

XI. Program Code: (Teacher must assign separate program statement


to group of 3-4 student)

1. Write a program using ADO.Net to connect to the database.


Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim conn As New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data ” &

“Source=C:\Users\Suresh\Documents\Visual Studio 2012 \ Projects \ Datagrid


\

stud.mdb”)

Conn.Open()

Dim cmd As New OleDbCommand(“Select * From Marks”, conn)

Dim da As New OleDbDataAdapter(cmd)

Dim ds As New DataSet

da.Fill(ds, “Marks”)

DataGrid1.CaptionText = “marks”

DataGrid1.DataSource = ds
DataGrid1.DataMember = “marks”

End Sub

End Class

XII. Results (Output of the Program)

XIII. Practical Related Questions


Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.

• Find error from following code Dim con As New

OledbConnection (“Provider=microsoft.oledb.4.0DataSource=D:\mydata.accdb ;”)

• Write a connection string with MS-access using any

(Space for answers)

1. Find error from following code

Dim con As New

OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0DataSource=D:\mydata.accdb;”
)

• Error 1: Type expected.


Error 2: ‘OleDbConnection’ is a type and cannot be used as an expression.

Error 3: ‘Conn’ is not declared. It may be inaccessible due to its protection level.

2. Write a connection string with MS-access using any database.

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDB.accdb

XIV. Exercise (Teacher must assign separate exercise to group of 3-4


student)

• Design the windows application that will dispaly the content of a table in MS-
Access database on DataGrid control using data

(Space for answers)

1. Design the windows application that will display the content of a table in
MS-Access database on DataGrid control using data adapter.

Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


Dim conn As New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data” &
“Source=C:\Users\Suresh\Documents\Visual Studio 2012\Projects\DataGrid1
\student.mdb”)

Advertisements
conn.Open()

Dim cmd As New OleDbCommand(“Select *From Student”, conn)

Dim da As New OleDbDataAdapter(cmd)

Dim ds As New DataSet

da.Fill(ds, “Roll Call”)

DataGrid1.CaptionText = “Student”

DataGrid1.DataSource = ds

DataGrid1.DataMember = “Roll Call”

End Sub

End Class

OUTPUT:

You might also like