0

当我想为我的数据列表开发无限滚动时,我遇到了一些错误,例如“将 nvarchar 值'xty1kq00oktl2omikmznuqle' 转换为数据类型 int 时转换失败。”这个错误是什么。我的代码有什么问题.

if (Session["id"] != null)
{
mydb db = new mydb();
//Fetch records initially.
 DataSet dsProducts = db.GetProducts();
/ /Bind data to gridview
dl.DataSource = dsProducts;
 dl.DataBind();
    }

 }


  }

    public class mydb
  {
  private SqlConnection con;
   public mydb()
  {
   con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
     }

public DataSet GetProducts()

{

    SqlCommand cmd = new SqlCommand("select top 5 decription,url from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id where tb_userlogin.id=@id", con);
      cmd.Parameters.AddWithValue("@id", id);

    SqlDataAdapter da = new SqlDataAdapter(cmd);
      DataSet ds = new DataSet();
   da.Fill(ds);
      return ds;
      error:Conversion failed when converting the nvarchar value 'xty1kq00oktl2omikmznuqle' to data type int.i have little bit confusion at this error
       }

       public DataSet FetchNextProducts(int id, int recordsCount)
         {
    DataSet ds = new DataSet();
      string query = string.Format("select top {0} * from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id where tb_userlogin.id=@id ASC", id);
SqlCommand cmd = new SqlCommand(query, con);
   SqlDataAdapter adapter = new SqlDataAdapter(cmd);
    adapter.Fill(ds);
    return ds;
     }

     how can i overcome this

      Thanks and Regards 
4

0 回答 0