Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从ASP.NET调用SQL SERVER时返回错误的结果(始终返回上次请求的结果) 标题_C#_Asp.net_Sql Server_Iis_Asp.net 2.0 - Fatal编程技术网

C# 从ASP.NET调用SQL SERVER时返回错误的结果(始终返回上次请求的结果) 标题

C# 从ASP.NET调用SQL SERVER时返回错误的结果(始终返回上次请求的结果) 标题,c#,asp.net,sql-server,iis,asp.net-2.0,C#,Asp.net,Sql Server,Iis,Asp.net 2.0,我有以下代码: string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection connection = new SqlConnection(connStr); SqlCommand command = new SqlCommand("spTestProcedure", connection); command.CommandType = Com

我有以下代码:

string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(connStr);
SqlCommand command = new SqlCommand("spTestProcedure", connection);
command.CommandType = CommandType.StoredProcedure;
int test = int.Parse(Request.QueryString["test"]);
command.Parameters.AddWithValue("@Test", test);

SqlDataAdapter da = new SqlDataAdapter(command);

DataTable dt = new DataTable();
da.Fill(dt);
出于某种原因,它总是返回最后一个请求的结果。 例如:

第一个请求&测试=111不返回任何结果 第二次请求和测试=222返回111的结果 第三次请求和测试=111返回222的结果 第四个请求&测试=111返回111的结果 请求可以来自不同的客户端,结果是相同的

当直接从SQLServerManagementStudio执行时,存储过程总是返回良好的结果

该网站是在共享主机上运行的,发生这种情况时,它的负载似乎很重


有没有可能与代码相关,或者与此服务器相关?

服务器今天给了我另一个线索:

我正在浏览B页,打开A页后不久

页面A因以下错误而崩溃:

System.Data.SqlClient.SqlException:找不到存储过程“spThatIsOnlyPresentOnPageB”

似乎服务器通常无法正确处理SqlCommands


是时候换服务器了。谢谢你们的想法,伙计们

这是经常发生还是仅当系统负载较重时才会发生?与您的问题不完全相关,但…仅当系统负载较重时才会发生。在此期间,在同一服务器上运行的其他网站上也会出现其他随机问题。@SeanLange谢谢,我会看一看。在哪种情况下调用此代码?这是正常的页面循环还是部分页面循环?