Conversion failed when converting the nvarchar value 'xty1kq
Hai Al,
when i'm developing unlimted scroll down ,i have facing the fallowing errrors.(i'm highlighting those)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace holdurl
{
public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string id = System.Web.HttpContext.Current.Session.SessionID;
if (Session["id"] != null)
{
mydb db = new mydb();
//Fetch 14 records initially.
DataSet dsProducts = db.GetProducts();
//Bind data to gridview
dl.DataSource = dsProducts;
dl.DataBind();
}
}
protected void btnGetMoreRecords_Click(object sender, EventArgs e)
{
mydb db = new mydb();
//Fetch 5 records initially.
DataSet dsProducts = db.FetchNextProducts(Convert.ToInt32(hiddenLastProductID.Value), 5);
i think i'm missing something about this line ,i'm not able to solve it.
dl.DataSource = dsProducts;
dl.DataBind();
}
public class mydb
{
private SqlConnection con;
public mydb()
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
}
public DataSet GetProducts()
{
string id = System.Web.HttpContext.Current.Session.SessionID;
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;
Conversion failed when converting the nvarchar value 'xty1kq00oktl2omikmznuqle' to data type int.
}
public DataSet FetchNextProducts(int id, int recordsCount)
{
// string id = System.Web.HttpContext.Current.Session.SessionID;
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);
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand(query, con);
cmd.Parameters.AddWithValue("@id", id);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
return ds;
}
public object id { get; set; }
}
protected void btngoto_Click(object sender, EventArgs e)
{
Response.Redirect("userdata1.aspx");
}
}
}
can any one help me out
Thanks and Regards