Populer Topics

Connection Class

For any type of database operation connection is first class to do In ADO.Net whenever we require than we are using connected architecture or disconnected architecture.Connection class will be common for all connection class provide following property.

Property Description

This connection string which is used to open SQL server connection. If we use sql connection than we do not pass any parameter.


It will get or set the timeout limit which has already open after connection timeout is raised error.


This will specifies the name of database server which we are    connected or going to connect after opening the connection.

DataSource This will give the name of database instance which we are connected.
ServerVersion It will give us version details of sql server which we are connected.


using System;
using System.Data.SqlClient;
using System.Data;

namespace Codeplanex
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            SqlConnection con = new SqlConnection();
            SqlConnection ConWithString = new SqlConnection(@"Data Source=.\MSSQLEXPRESS;Initial Catalog=Demo;Integrated Security=True");


Property Description

This method is used to open the connection.


This method is used to close connection.


Allow us to create object of the sql command which is used in connected architecture.  When we connect our database to web application we must use provider with connection. It may either be sql, oracle, oledb.