Define public class adjustment stored procedures Get data: use system; use system.data.sqlclient; use system.configuration;
A summary description of Namespace JSFW {///
public DataSet Runprocedure (string strConn, string strSpname, SqlParameter [] arrayParameters, string strTablename) {SqlConnection myconnection = new SqlConnection (strConn); DataSet dsData = new DataSet (); SqlDataAdapter mycommand = new SqlDataAdapter (strSpname, myconnection); mycommand.SelectCommand .CommandType = CommandType.StoredProcedure; SqlParameter arrayParameter = new SqlParameter (); foreach (SqlParameter sq in arrayParameters) {mycommand.SelectCommand.Parameters.Add (sq);} mycommand.Fill (dsData, strTablename); myconnection.Close (); Return DSData;
}
public void Runprocedure (string strConn, string strSpname, SqlParameter [] arrayParameters) {SqlConnection myconnection = new SqlConnection (strConn); myconnection.Open (); SqlCommand mycommand = new SqlCommand (strSpname, myconnection); mycommand.CommandType = CommandType.StoredProcedure; Sqlparameter arrayparameter = new sqlparameter (); foreach (sqlparameter sq in arrayparameters) {mycommand.parameters.add (sq);} mycommand.executenononNection.Close ();
}
public int Runprocedure (string strConn, string strSpname, SqlParameter [] arrayParameters, int nEffectedrows) {SqlConnection myconnection = new SqlConnection (strConn); myconnection.Open (); SqlCommand mycommand = new SqlCommand (strSpname, myconnection); mycommand.CommandType = CommandType .StoredProcedure; SqlParameter arrayParameter = new SqlParameter (); foreach (SqlParameter sq in arrayParameters) {mycommand.Parameters.Add (sq);} nEffectedrows = mycommand.ExecuteNonQuery (); myconnection.Close (); return nEffectedrows;} public DataSet Runprocedure (string strConn, string strSpname, string strTablename) {DataSet dsData = new DataSet (); SqlConnection myconnection = new SqlConnection (strConn); myconnection.Open (); SqlDataAdapter mycommand = new SqlDataAdapter (strSpname, myconnection); mycommand.SelectCommand.CommandType = CommandType.StoredProcedure; MyCommand.Fill (DSData, Strtables); MyConnection.Close (); Return DSDATA;
}
Public Bool Checkeof (Dataset DSDATA) {Bool Breturn = false; if (dsdata! = null) {if (dsdata.tables.count> 0) {for (INT i = 0; i
}
When calling: public class clsAds: DataAccessBase {public string strConn = ConfigurationSettings.AppSetting [ "connString"] ToString (); public DataSet GetAds (int nPositionID) {DataSet dsData = new DataSet (); SqlParameter [] sql = {new SqlParameter. ("@PositionID", SqldbType.int)}; sql [0] .value = npositionid; dsdata = this.Runprocedure (StrConn, "sp_getads", sql, "ads"); return dsdata;}}