我在 jquery 中有 15 个同时执行的 ajax 调用,调用它们各自的 c# 函数(每个 ajax 有单独的 c# 函数)以下是示例 c# sql 函数
public static DataSet Function1(int arg, string arg2, string arg3, string arg4, int arg5, int arg6)
{
DataSet ds = new DataSet();
try
{
using (SqlConnection con = DbHelper.Connect())
{
con.Open();
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "Procedure_Name";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@arg", arg);
cmd.Parameters.AddWithValue("@arg1", arg1);
cmd.Parameters.AddWithValue("@arg2", arg2);
cmd.Parameters.AddWithValue("@arg3", arg3);
cmd.Parameters.AddWithValue("@arg4", arg4);
// cmd.Parameters.AddWithValue("@arg5", arg5);
cmd.CommandTimeout = 0;
var dataAdaptor = new SqlDataAdapter(cmd);
dataAdaptor.Fill(ds);
}
con.Close();
}
ds.Tables[0].TableName = "Test";
}
catch (Exception ex)
{
throw ex;
}
return ds;
}
我偶尔会遇到以下异常
Message:Object reference not set to an instance of an object.
Source:System.Data
Target site:Boolean TryOpenInner(System.Threading.Tasks.TaskCompletionSource1[System.Data.ProviderBase.DbConnectionInternal])
Stack Trace: at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.Open()
幕布斯7119047
相关分类