Asp.net并发呼叫问题

时间:2017-11-04 15:15:16

标签: c# asp.net concurrency

我在iis上托管了一个asp.net Web应用程序,它返回报告。我有一个sql存储过程在显示结果上调用(下面是代码)。当两个用户在同一时间点击时,计数全部搞砸了。清楚数据集。我试图将会话状态设置为页面指令为false并且只读,但它仍然不起作用

SqlCommand cmdcount = new SqlCommand("sp_GetCount", con);
cmdcount.CommandTimeout = Convert.ToInt16(ConfigurationManager.AppSettings["CommandTimeOut"]);
cmdcount.CommandType = CommandType.StoredProcedure;

cmdcount.Parameters.AddWithValue("@Code", DpAc.SelectedItem.Value);
cmdcount.Parameters.AddWithValue("@No", Dpfno.SelectedItem.Value);
cmdcount.Parameters.AddWithValue("@Date", caltextbox.Text);
DataTable dt_ps = new DataTable();
SqlDataAdapter da = new SqlDataAdapter();

con.Open();
da.SelectCommand = cmdcount;
da.Fill(dt_ps);
Count.DataSource = dt_ps;
Count.DataBind();
d_ps.Clear();
Count.Visible = true;
con.Close();

下面添加到.aspx页面

<% Page EnableSessionState="ReadOnly"%> and

<% Page EnableSessionState="False"%>

输出用户1

35计数

输出用户2

数45

预期:两个用户的输出都应为30

0 个答案:

没有答案
相关问题