Skip to content
Loading
  • Salman Beg
    0
    First create a class. Get connection string from web.config. Write the code for opening connection and everything. So whenever you want to perform any operation like crud then create the object of the class and call that method. Thanks.
    0
  • 0
    Hi
    Thank you Salman Beg for you time. I am sorry I have not posted enough information. Here is what I have in mind
     
    I create the class dbConnection
     
    using system.configuration;
    using system.data;
    using system.data.sqlClient;
     
    Namespace dbConnection
    {
      Public class SqlConnection Connection
      private sqlConnection _mycon = new SqlConnection;
      private string _constring;
     
      _constring = ConfigurationManager.ConnectionString[0].ConnectionString;
      _mycon.ConnectionString = _constring;
     return _mycon
    }
     
    Now I create another class employee.cs
     
     
    public list T
    {
      connection MyCon = new Connection();
      .....
      MyCon.open
    }
     
     I am trying to achieve something like this but I cannot can someone point me my mistakes and help with a solution.
     
     Thanks in advance
     
    Schleid
    0
  • Salman Beg
    0
    You need to define everything inside class. Open the connection also inside the method. After that call it. Thanks.
    0
  • 0
    I have done that but somehow I cannot create the object from the connection.
    Would you please post the code? I would really appreciate
     
    Regard
    0