aditya immadi

aditya immadi

  • NA
  • 205
  • 71.6k

id does not exist in curent context

Jan 24 2014 2:01 AM
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 
 
 
 

Answers (5)