//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); }
private static void Open() { var sConStr = ClsComm.SqlConnectionString(); SqlConnection Con = new SqlConnection(sConStr); if (Con.State != ConnectionState.Open) { Con.Open(); } }
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()); }
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); }
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); }
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]); }
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); }
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); }
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()); }