using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace LibraryMembers
{

    class FirstClass
    {
        SqlConnection con;
        public SqlCommand cmd;
        DataTable dt;
        SqlDataAdapter da;

        public FirstClass()
        {
            con = new SqlConnection(Properties.Settings.Default.LibraryMembersConnectionString.ToString());
            cmd = new SqlCommand();
            dt = new DataTable();
            cmd.Connection = con;
            da = new SqlDataAdapter(cmd);
        }

        public DataTable dbOut(string sql)
        {
            cmd.CommandText = sql;
            con.Open();
            da.Fill(dt);
            con.Close();
            return dt;
        }
        
        public void exeCommand(string strName)
        {
            con.Open();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = strName;
            cmd.ExecuteNonQuery();
            con.Close();

        }
        public void exeCommand1(string strName)
        {
            try
            {
                cmd.CommandText = strName;
                con.Open();
                cmd.ExecuteNonQuery();
            }
            catch { }
            finally
            {
                con.Close();
            }

        }
    }
}
