Sessions and using data from another page [Resolved]

Posted by Icewolf0927 under Silverlight on 2/17/2011 | Points: 10 | Views : 1785 | Status : [Member] | Replies : 13
Hi
I have two issues they are about the same think just in different spots. The first one I am trying to understand how to get a value at a time when someone logs in. What i have is a table that house user name and passwords what i would like to get is the primary key from that table. I would need to be able to use value to update another table when they click on a row on a datagrid. I have looked into the session value but I don't understand how that works. The value that I want is a interger.


The other issue is that i have screen to allow them to sign up to a webpage. The problem is that I have the user name and passwords on a different table. I am not sure how to get the value back when they add their information. I have attached the code that I have so far for this. I am just not sure how to call the value once it pulls it back.

        [OperationContract]
public void InsertMember(Member m)
{
using (AddMemberDataContext amd = new AddMemberDataContext())
{
Member mb = new Member()
{
Fname = m.Fname,
Lname = m.Lname,
City = m.City,
State = m.State,
Addr1 = m.Addr1,
Addr2 = m.Addr2,
Phone = m.Phone,
Zip = m.Zip
};

amd.Members.InsertOnSubmit(mb);
try
{
amd.SubmitChanges();
int mid = mb.MemberID;
}
catch (Exception)
{
throw;
}


}
}





Responses

Posted by: Vuyiswamb on: 2/22/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 50

Up
0
Down

Resolved
The Design is somehow strange, i dont see why you would put the username and the password in different tables, but if you do you must have some keys that can allow you to get it back . i have written an article on a basic login system one can implement
http://www.dotnetfunda.com/articles/article808-how-to-write-a-simple-login-page-in-aspnet-.aspx

about the Session , you can just add the ID on the session like this

Session["MYID"] = 1;



and retrieve it like this


int MyID = Covnert.Toint32(Session["MYID"]);



I hope i understand your question Clearly


Thank you for posting at Dotnetfunda
[Administrator]

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Icewolf0927 on: 2/22/2011 [Member] Starter | Points: 25

Up
0
Down
Is there no one that can help me with my issue. Mostly right now i would like to understand how to get the unique id when someone logs into my database.

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/22/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
When ever a user logs in (Assume registered user) get his ID during the authentication process from DB and save it in session and use this the way you need. Hope I had answered your question.



Thanks and Regards
Madhu

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/22/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Try to create a unique id every time user logs in and save it and retrive it as per your requirement.

Thanks
Karthik
www.f5Debug.net

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Icewolf0927 on: 2/23/2011 [Member] Starter | Points: 25

Up
0
Down
yes thank you. I thought it was a good Idea at first but then I moved it to the other table. So when i create the Session do I need create a class to call this later or do I put in on the app.xaml.cs?

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/23/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hw abt GUID??

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Icewolf0927 on: 2/23/2011 [Member] Starter | Points: 25

Up
0
Down
Sorry i am still kind of new to this what is GUID?

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/27/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Check this link

http://www.dotnetspider.com/resources/193-What-GUID-How-generate-GUID.aspx

Thanks and Regards
Madhu

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/27/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
A GUID represents a Unique identifier - means you cannot generate the same GUID
more than once, kinda unique number.

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/28/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hope you are now clear abt GUID..

Thanks and Regards
Madhu

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Icewolf0927 on: 2/28/2011 [Member] Starter | Points: 25

Up
0
Down
yes thank you I got it to work now. Thanks for all your help

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/28/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Welcome!!!

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/28/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
welcome ... Happy coding

Thanks and Regards
Madhu

Icewolf0927, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response