First create procedure. . .
ALTER PROCEDURE dbo.user1
@id int=0
AS
select * from user_reg where uid=@id;
RETURN
And follow code about aspx.cs
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//grid();
profile();
}
}
protected void profile()
{
con.Open();
SqlCommand cmd = new SqlCommand("user1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", Session["login"].ToString());
cmd.Parameters.AddWithValue("@flag", 1);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
Label3.Text = dt.Rows[0]["uadd"].ToString();
Label7.Text = dt.Rows[0]["ucity"].ToString();
Label5.Text = dt.Rows[0]["ustate"].ToString();
Label9.Text = dt.Rows[0]["upincode"].ToString();
Label11.Text = dt.Rows[0]["umobno"].ToString();
Label13.Text = dt.Rows[0]["ugender"].ToString();
Label15.Text = dt.Rows[0]["ulang"].ToString();
Label17.Text = dt.Rows[0]["uemailid"].ToString();
Label1.Text = dt.Rows[0]["uname"].ToString();
Image1.ImageUrl = dt.Rows[0]["uimage"].ToString();
}
}
}
ALTER PROCEDURE dbo.user1
@id int=0
AS
select * from user_reg where uid=@id;
RETURN
And follow code about aspx.cs
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//grid();
profile();
}
}
protected void profile()
{
con.Open();
SqlCommand cmd = new SqlCommand("user1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", Session["login"].ToString());
cmd.Parameters.AddWithValue("@flag", 1);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
Label3.Text = dt.Rows[0]["uadd"].ToString();
Label7.Text = dt.Rows[0]["ucity"].ToString();
Label5.Text = dt.Rows[0]["ustate"].ToString();
Label9.Text = dt.Rows[0]["upincode"].ToString();
Label11.Text = dt.Rows[0]["umobno"].ToString();
Label13.Text = dt.Rows[0]["ugender"].ToString();
Label15.Text = dt.Rows[0]["ulang"].ToString();
Label17.Text = dt.Rows[0]["uemailid"].ToString();
Label1.Text = dt.Rows[0]["uname"].ToString();
Image1.ImageUrl = dt.Rows[0]["uimage"].ToString();
}
}
}
0 comments:
Post a Comment