建议先在 sqlCommand1.ExecuteReader();执行是加上 try{}catch{} 比如
.....
sqlConnection1.Open();
try
{
sqlCommand1.ExecuteReader();
}
catch(Exception ex)
{
Console.WriteLine( ex.ToString());
}
在sqlCommand1.ExecuteReader()处设置断点 然后按F11单步跟踪,看看ex.ToString()输出的是什么,然后再告诉我.
.....
sqlConnection1.Open();
try
{
sqlCommand1.ExecuteReader();
}
catch(Exception ex)
{
Console.WriteLine( ex.ToString());
}
在sqlCommand1.ExecuteReader()处设置断点 然后按F11单步跟踪,看看ex.ToString()输出的是什么,然后再告诉我.
放在try-carch中吧,处理一下异常吧
这个值是output的,可以再赋值吗???我想应该这样写!如下:
sAnswer = sqlCommand1.Parameters.Add("@sResult", SqlDbType.NVarChar, 160).Value ;
using System.Data.SqlClient;
scom=new SqlCommand("updateWriteStockTotalApp",(SqlConnection)Application["scon"]);
scom.CommandType=CommandType.StoredProcedure;
scom.Parameters.Add(new SqlParameter("@tId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@ProjectId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@departmentId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@userId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@tDate",SqlDbType.DateTime));
scom.Parameters.Add(new SqlParameter("@surrogateDepId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@flowId",SqlDbType.VarChar,50));
scom.Parameters.Add(new SqlParameter("@username",SqlDbType.VarChar,50));
scom.Parameters["@username"].Value=username;
scom.Parameters["@tId"].Value=tId;
scom.Parameters["@ProjectId"].Value=ProjectId;
scom.Parameters["@departmentId"].Value=departmentId;
scom.Parameters["@userId"].Value=userId;
scom.Parameters["@tDate"].Value=tDate;
scom.Parameters["@surrogateDepId"].Value=surrogateDepId;
scom.Parameters["@flowId"].Value=flowId;
scom.Parameters.Add(new SqlParameter("@who",SqlDbType.VarChar,50));
scom.Parameters["@who"].Value=soc;
retuInt=scom.ExecuteNonQuery();
return retuInt;
sqlCommand1.Parameters.Add("@sResult", SqlDbType.NVarChar, 160); //output
sqlCommand1.Parameters["@sResult"].Direction = ParameterDirection.Output;
1.数据类型不对
2.output的参数用法搞错了!