منون میشم تا انتها کمکم کنید .
این قطعه کد مربوط به لایبراری DAL و کلاس Base هست :
public SqlDataReader ExecuteReaderWitParameters(out SByte result, CommandType commandType, string commandText, SqlParameter[] commandParameters)
{
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = commandType;
cmd.CommandText = commandText;
cmd.Parameters.AddRange(commandParameters);
bool mustCloseConnection = false;
try
{
if (con.State != ConnectionState.Open)
{
mustCloseConnection = true;
con.Open();
}
else
{
mustCloseConnection = false;
}
dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) ;
result = 100;
return dataReader;
}
catch
{
if (mustCloseConnection)
con.Close();
dataReader = null;
result = -100;
return dataReader;
}
}
این هم مربوط به لایبراری DAL و کلاس Total:
public SqlDataReader GetAllPrivateTotal(out sbyte result, string start)
{
return ExecuteReaderWitParameters(out result, CommandType.StoredProcedure, "S_All_Private_Total", new SqlParameter[] {
new SqlParameter ("@start" , start)});
}
اینم کد مربوط به لایبراری BLL و کلاس Total :
public static List<Total> GetAllPrivatTotal(out sbyte result, string start)
{
DAL_Acc_Fakke.Total dalTotal = new DAL_Acc_Fakke.Total();
IDataReader idrTotal = dalTotal.GetAllPrivateTotal(out result,start);
if (result == 100)
{
List<Total> totalList = new List<Total>();
while (idrTotal.Read())
{
Total tempTotal = new Total();
tempTotal.Text = idrTotal["Text"].ToString();
totalList.Add(tempTotal);
}
return totalList;
}
return null;
}
من چون نمیدونستم باید چطور این کار رو انجام بدم اومدم از یک آرگومان به نام Result استفاده کردم و اگه اون برابر با -100 بود یعنی کدم خطا داشته . حالا باید چی کار کنم . بی زحمت یه کم کامل توضیح بدید .
ممنون و تشکر از وقتی که گذاشتید