当我开始为我的数据列表开发无限滚动时,我面临一些错误,例如“将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