Conversion failed when converting the nvarchar value to data type int

后端 未结 2 1808
故里飘歌
故里飘歌 2021-01-26 11:05

I am getting the error of conversion failed in my codebehind. My code is below:

using (SqlCommand cmd = new SqlCommand((tempUsertype == \"0\" ? \"Select * from t         


        
2条回答
  •  余生分开走
    2021-01-26 11:35

    Try this:

    cmd.Parameters.Add("@NgoId", SqlDbType.Int).Value = Convert.ToString(Session["User"]);
    

    This will coerce the NgoId parameter to the SQL Server int data type.

提交回复
热议问题