我的ASP.NET MVC内部网中有此功能,可显示每周范围内员工的工作量。此WeeklyMonitoring
页面有一个存储过程,可选择以下信息:Company
,Name
,ExpectedWorkTime
和RecordedTime
,具体取决于所选周。
以下是我如何调用此存储过程以及如何保存所选数据:
conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand("spGetWeeklyActivityByEmployee", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@startDate", wk1)); //wk1 is the starting week of the time range
cmd.Parameters.Add(new SqlParameter("@endDate", wk2)); //wk2 is the ending week of the time range
rdr = cmd.ExecuteReader();
string[] tab_company = new string[9999];
string[] tab_name = new string[9999];
string[] tab_expectedtime = new string[9999];
string[] tab_rectime = new string[9999];
int counter;
counter = 0;
while (rdr.Read())
{
tab_company[counter] = rdr["Company"].ToString();
tab_name[counter] = rdr["Name"].ToString();
tab_expectedtime[counter] = rdr["Expected Time"].ToString();
tab_rectime[counter] = rdr["Recorder Time"].ToString();
counter++;
}
对所有这些技术都不熟悉(无论是ASP.NET MVC还是SQL Server 2008),我没有找到避免为string[]
设置固定缓冲区大小的方法。
这样的事情会有可能吗?如何根据从数据库中检索的数据量来确定缓冲区大小的数据?