Link to home
Start Free TrialLog in
Avatar of dshi15
dshi15Flag for United States of America

asked on

Database Connection Class in C#

Hi Expert,

I like write a standard class to connect to database and my data entity, then i can call it in other class, how i can do it? db is working here.

Thanks in advance.


class DataConn
    {
        public DataConn()
        { 

		try
                {
                string Conn = DBConnection.GetConnectionString("ConnectionString");
                if (!string.IsNullOrEmpty(Conn))
                {
                    using (Entities1 db = new Entities1(Conn))
                    {
                    }
                }
                }
              catch (Exception ex)

              {
                  
              }
 
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial