Sqlparameter[] prams= new Sqlparameter[sqlparameterlist.count];
for (int i=0;i<sqlparameterlist.count;i++)
{
prams[i]= (SqlParameter) sqlparameterlist[i];
}
#endregion
Try
{
Data. Runproc ("getscoresetting", prams, out dataAdapter);
DataSet DataSet = new DataSet ();
DataAdapter.Fill (DataSet, "table");
Dataadapter.dispose ();
if (dataset.tables["table"). Rows.Count = 0)
{
DataSet.Clear ();
Dataset.dispose ();
return false;
}
Else
{
foreach (DataRow dr in dataset.tables["table"). Rows)
{
scoresetting SS = new scoresetting ();
Ss.id= Int32.Parse (dr["Scoresettingid"). ToString (). Trim ());
Ss. Functionid= Int32.Parse (dr["FunctionID"). ToString (). Trim ());
Ss. Operationid= Int32.Parse (dr["OperationID"). ToString (). Trim ());
Ss. Roletypeid= Int32.Parse (dr["Roletypeid"). ToString (). Trim ());
Ss. Bbstypeid= Int32.Parse (dr["Bbstypeid"). ToString (). Trim ());
Ss. Score= Int32.Parse (dr["Score"). ToString (). Trim ());
Ss. bb= Int32.Parse (dr["BB"). ToString (). Trim ());
Ss. Buytype= Int32.Parse (dr["Buytype"). ToString (). Trim ());
Ss. Functionstate= Int32.Parse (dr["Functionstate"). ToString (). Trim ());
ADD (SS);
}
DataSet.Clear ();
Dataset.dispose ();
return true;
}
}
catch (Exception ex)
{
Error.Log ("Town", ex. ToString ());
Dataadapter.dispose ();
return false;
}
Finally
{
Data. Close ();
Data. Dispose ();/release Database
}
}
#endregion
}
}
A little note:
The code for classifying data-tier classes is divided into six blocks: private members, constructors, public properties, indexes, private methods, and public methods. This establishes the index for the class, which is the necessary element of the collection class. Then there is a private method, the role is to add objects to the collection, the public method is a query method, the above example is passed through the parameter, in fact, can also be used to pass the attribute. There is a convention that if the value of 1 is passed, the variable does not work, basically the same as the idea in the stored procedure. The Scoresetting object in this example is another separate class, as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.