Hai all,
i'm facing a stupid problem.hope you guys help me out .when i'm trying to binding the records
string id = System.Web.HttpContext.Current.Session.SessionID;
if (IsPostBack == false)
{
string connn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection con = new SqlConnection(connn);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "spuserdata";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id",id);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);--------convertion failed to convert nvarchar to int
DataList1.DataSource = ds;
DataList1.DataBind();
when i tried like this cmd.Parameters.AddWithValue("@id",Convert.ToInt32("id"));--- it says input string is not in correct formate
how can i solve this
and my stored proc is
ALTER procedure [dbo].[spuserdata](
@id int)
AS
Begin
select decription,name from tb_userdata inner join tb_userlogin on tb_userdata.uidfromtb1=tb_userlogin.id
where tb_userlogin.id=@id
End
Thanks and Regards
Biswa Pujarini MohapatraPosted Jan 24, 2014, 4:07 AM
probably you have to change your store procedure and database accordingly
aditya immadiPosted Jan 24, 2014, 3:17 AM
session["id"]=System.Web.HttpContext.Current.Session.SessionID;
can you please tell me how can i get current user session id ?
Biswa Pujarini MohapatraPosted Jan 24, 2014, 2:38 AM
I think in your code you have to store the Loginid in a session
like Session["LoginID"]=123;
then you can convert session to int32
aditya immadiPosted Jan 24, 2014, 2:25 AM
Biswa Pujarini MohapatraPosted Jan 24, 2014, 2:13 AM
cmd.Parameters.AddWithValue("@id",Int32.TryParse("id"));
hope it helps