TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aditya immadi
NA
205
71.5k
Retrieving id and Name for Already Login User using Sessions
Sep 17 2013 3:10 PM
Hai All,
I write this code for inserting user data if he is already existing user.but i need to get his name and current id using sessions ,after that i can send other details along with these two to my DB.how can i do this
on page load
// string name = Session["nameforlogin"].ToString();
// string id = Session["id"].ToString();
on button click
SqlConnection conn = new SqlConnection();
conn.ConnectionString="Data Source=USER-PC\\ADITYA;Initial Catalog=holder;Persist Security Info=True;User ID=sa;Password=123";
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "insert into tb_userdata (employeeidfromtable1,Name,dicription,aboutme) values ('" +( Session["id"]) + "','" + Session["name"] + "','" +txtdesr.Text + "','"+txturl .Text+"');";
cmd.ExecuteNonQuery();
conn.Close();
thanks and regards
Reply
Answers (
8
)
Object Reference not set to an Instance of an Object.Error
Free Web Host Server for ASP.Net