예제 #1
0
        //public static SqlConnection Con;

        public ClsSql()
        {
            var           sConStr = ClsComm.SqlConnectionString();
            SqlConnection Con     = new SqlConnection(sConStr);
            var           ConStr  = ClsComm.sqlConectionStr_IntDB();
            SqlConnection Conn    = new SqlConnection(ConStr);
        }
예제 #2
0
        private static void Open()
        {
            var           sConStr = ClsComm.SqlConnectionString();
            SqlConnection Con     = new SqlConnection(sConStr);

            if (Con.State != ConnectionState.Open)
            {
                Con.Open();
            }
        }
예제 #3
0
        public static SqlDataReader GetReader(string commandQuery)
        {
            string        connectionString = ClsComm.SqlConnectionString();
            SqlConnection connection       = new SqlConnection(connectionString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            SqlCommand command = new SqlCommand(commandQuery, connection);

            return(command.ExecuteReader());
        }
예제 #4
0
        public static void ExcuteCommand(string excutestatment)
        {
            string sConStr = ClsComm.SqlConnectionString();
            //string connectionString = ConfigurationManager.ConnectionStrings["SQLCon"].ToString;
            SqlConnection con = new SqlConnection(sConStr);

            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            var sqlcmd = new SqlCommand(excutestatment, con);

            sqlcmd.ExecuteNonQuery();
            Close(con);
        }
예제 #5
0
        public static DataTable SelectData(string selectStatment)
        {
            string        connectionString = ClsComm.SqlConnectionString();
            SqlConnection connection       = new SqlConnection(connectionString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            var dt = new DataTable();

            var da = new SqlDataAdapter(selectStatment, connection);

            da.Fill(dt);

            return(dt);
        }
예제 #6
0
        public static object GetQryVal(string Qry)
        {
            string connectionString = ClsComm.SqlConnectionString();
            //string connectionString = ConfigurationManager.ConnectionStrings["SQLCon"].ToString;
            SqlConnection connection = new SqlConnection(connectionString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            SqlCommand     selectCommand = new SqlCommand(Qry, connection);
            SqlDataAdapter adapter       = new SqlDataAdapter(selectCommand);
            DataSet        dataSet       = new DataSet();

            adapter.Fill(dataSet);
            connection.Dispose();
            return(dataSet.Tables[0].Rows[0][0]);
        }
예제 #7
0
        public static DataSet GetDs2(string Qry)
        {
            string connectionString = ClsComm.sqlConectionStr_IntDB();
            //string connectionString = ConfigurationManager.ConnectionStrings["SQLCon"].ToString;
            SqlConnection connection = new SqlConnection(connectionString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            SqlCommand     selectCommand = new SqlCommand(Qry, connection);
            SqlDataAdapter adapter       = new SqlDataAdapter(selectCommand);
            DataSet        dataSet       = new DataSet();

            adapter.Fill(dataSet, "SMData");
            connection.Dispose();
            return(dataSet);
        }
예제 #8
0
        public static string gRun_select(string sQry)
        {
            string str1    = "";
            string sConStr = ClsComm.SqlConnectionString();
            //string connectionString = ConfigurationManager.ConnectionStrings["SQLCon"].ToString;
            SqlConnection con = new SqlConnection(sConStr);

            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }

            var dt = new DataTable();
            var da = new SqlDataAdapter(sQry, con);

            da.Fill(dt);
            str1 = (dt.Rows.Count != 0) ? dt.Rows[0][0].ToString() : "";
            dt.Dispose();
            da.Dispose();
            Close(con);
            return(str1);
        }
예제 #9
0
        public static SqlDataReader GetReader(string spName, SortedList parametersList)
        {
            string        connectionString = ClsComm.SqlConnectionString();
            SqlConnection connection       = new SqlConnection(connectionString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = spName;
            int count = parametersList.Count;

            for (int i = 0; i < count; i++)
            {
                string parameterName = parametersList.GetKey(i).ToString();
                object obj2          = parametersList[parameterName];
                command.Parameters.Add(new SqlParameter(parameterName, obj2));
            }
            return(command.ExecuteReader());
        }