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 MohapatraRank #465 · 5.4K reputationPosted Jan 23, 2014, 9:13 PM EST
cmd.Parameters.AddWithValue("@id",Int32.TryParse("id"));
hope it helps
aditya immadi186 reputationPosted Jan 23, 2014, 9:25 PM EST
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Jan 23, 2014, 9:38 PM EST
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 immadi186 reputationPosted Jan 23, 2014, 10:17 PM EST
session["id"]=System.Web.HttpContext.Current.Session.SessionID;
can you please tell me how can i get current user session id ?
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Jan 23, 2014, 11:07 PM EST
probably you have to change your store procedure and database accordingly