Write a sample example of ADO.Net?

Write a sample example of ADO.Net?

using System;
using System.Data;
using System.Data.OleDb;

// Step 1.Open Database Connection
OleDbConnection conn = new
                      OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inventory\\inventory\\db\\invent.mdb;");

// Step 2.Connection database opened 
conn.Open();

// Step 3.Create DataSet and Command objects
OleDbCommand cmd = new OleDbCommand(
                            "SELECT * FROM empr4r",
                            conn);

// Step 4.Execute the command
cmd.ExecuteScalar();

// Step 5.Closed this connection 
conn.Close();

By:Rajesh Kr
Date:2030-09-10 00:00:00

using System;
using System.Data;
using System.Data.OleDb;

// Step 1.Open Database Connection
OleDbConnection conn = new                     OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\inventory\\inventory\\db\\invent.mdb;");

// Step 2.Connection database opened 
conn.Open();

// Step 3.Create DataSet and Command objects
OleDbCommand cmd = new OleDbCommand(
                            "SELECT * FROM empr4r",
                            conn);

// Step 4.Execute the command
cmd.ExecuteScalar();

// Step 5.Closed this connection 
conn.Close();

By:Rajesh Kr
Date:2030-09-10 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related ADO.net SUB Links

ADO.net SUB interview questions and answers for experienced and fresher