Frequently Asked Interview Questions

List all the steps to access data base using ADO.Net?

Create Connection
Create connection to data source; here I am using sql connection.
SQLConnection con= new SQLConnection(“datasource=localhost;database=Northwind; Integrated Security=true”)
Create command
SQLCommand cmd = new SQLCommand(“select * from Products”,con);
Execute command
Use either connected/disconnected architecture, Here I am using connected data model using DataReader.

SqlDataReader reader;
Con.open();
reader = cmd.ExecuteReader();
Close connection
Finally close the connection.
Con.Close();

Most Visited Pages

Home | Site Index | Contact Us