Tuesday, 12 May 2015

CONNECTION CLASS IN ASP.NET

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

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

namespace stockexpert1.Datalayer
{
    public class connection
    {
        SqlConnection con = new SqlConnection("Data Source=SYSTEM-02;Initial Catalog=DBNAME;Integrated Security=True");
        public SqlConnection serverConnection()
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            return con;


        }
    }
}

No comments:

Post a Comment