C# 中调用存储过程报错“ 将参数值从 String 转换到 Int32 失败。”
protectedvoidButton1_Click(objectsender,EventArgse){//stringsqlstr="select*fromxfglwh...
protected void Button1_Click(object sender, EventArgs e)
{
//string sqlstr = "select * from xfgl where Flag in ('1') and (grono<=(select min(grono) from zb where flag<>2))";
//string sqlstr = "select * from xfgl where Flag in ('1','2','3','6')";
//SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
//DataSet myds = new DataSet();
//sqlcon.Open();
DataSet MyDataSet = new DataSet();
System.Data.SqlClient.SqlDataAdapter DataAdapter = new System.Data.SqlClient.SqlDataAdapter();
if (sqlcon.State != ConnectionState.Open)
{
sqlcon.Open();
}
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand("starthouse", sqlcon);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@GroNO", SqlDbType.Int);
myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";
myCommand.Parameters.Add("@errormessage", SqlDbType.VarChar, 255);
myCommand.Parameters["@errormessage"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
DataAdapter.SelectCommand = myCommand;
String Returnsql;
Returnsql = myCommand.Parameters["@errormessage"].Value.ToString();
Returnsql = Returnsql.Trim();
if (Returnsql.Length > 0)
{
//Response.Write("<script>alert('错误信息"&Returnsql&"')</script>");
Response.Write("<script>alert('选房开始错误!')</script>");
}
else
{
Response.Write("<script>alert('选房开始成功!')</script>");
//Response.Redirect("qdgl.aspx");
}
//关闭连接
if (sqlcon.State == ConnectionState.Open)
{
sqlcon.Close();
}
//Page_Load(object sender, EventArgs e);
GridView1.DataBind();
} 展开
{
//string sqlstr = "select * from xfgl where Flag in ('1') and (grono<=(select min(grono) from zb where flag<>2))";
//string sqlstr = "select * from xfgl where Flag in ('1','2','3','6')";
//SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
//DataSet myds = new DataSet();
//sqlcon.Open();
DataSet MyDataSet = new DataSet();
System.Data.SqlClient.SqlDataAdapter DataAdapter = new System.Data.SqlClient.SqlDataAdapter();
if (sqlcon.State != ConnectionState.Open)
{
sqlcon.Open();
}
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand("starthouse", sqlcon);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@GroNO", SqlDbType.Int);
myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";
myCommand.Parameters.Add("@errormessage", SqlDbType.VarChar, 255);
myCommand.Parameters["@errormessage"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
DataAdapter.SelectCommand = myCommand;
String Returnsql;
Returnsql = myCommand.Parameters["@errormessage"].Value.ToString();
Returnsql = Returnsql.Trim();
if (Returnsql.Length > 0)
{
//Response.Write("<script>alert('错误信息"&Returnsql&"')</script>");
Response.Write("<script>alert('选房开始错误!')</script>");
}
else
{
Response.Write("<script>alert('选房开始成功!')</script>");
//Response.Redirect("qdgl.aspx");
}
//关闭连接
if (sqlcon.State == ConnectionState.Open)
{
sqlcon.Close();
}
//Page_Load(object sender, EventArgs e);
GridView1.DataBind();
} 展开
展开全部
myCommand.Parameters.Add("@GroNO", SqlDbType.Int);
myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";
@GroNO接受整型,但是你传的是字符串
myCommand.Parameters["@GroNO"].Value = "select GroNO from zb where grono = (select min(grono) from zb where flag<>2)";
@GroNO接受整型,但是你传的是字符串
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询