Hi there hope somone out there can hep me I am new to asp.net and sql server I have a sql server 2005 database that has all the membershhip tables installed I have my login set up on a Loign.aspx page and an admin page asseble if users are loged in I also have a table in my database containing contact information dows anyone know how I get the relevent contact information to display when the user logs in. Obiouly there are multiple users so I wish the contact info to show when they login I am using visual studio 2005 and sql server 2005 hope somone can help, anymore info just ask lee
Seeing as youre using the best programming language available ( ) I figure I should help... To get the data relevant to a logged in user you would need to use an SQL statement stating the logged in persons username, to get the username of the person logged in you can use "User.Identity.Name". So an example would be... Code: Dim myCommand As SqlCommand = New SqlCommand("SELECT telephone, address, email FROM contactinfo WHERE username = '" & User.Identity.Name & "'", connectionReference) connectionReference.Open() Dim myDataReader As SqlDataReader = myCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) If myDataReader.Read() Then Me.label1.Text = "Username : " & User.Identity.Name Me.label2.Text = "Your phone number is: " & myDataReader("telephone") Me.label3.Text = "Your address is: " & myDataReader("address") Me.label4.Text = "Your email is: " &myDataReader("email") Else response.write("something went wrong when finding the username... this shouldnt happen") end if - I should say this is just a quick mock up but should in theory work and also gives you an idea of what you would need to do.
Hi there thanks for the replt that worked fine but then I need away to store the username in my second table whenever a new user is create, Im told that could be long winded. On checking around I noticed that the createuserwizard can be customized to save additional information by customizing the control using profiles or somthing, have read loads of tutorials but non realy explaine how to do the whole process andd where the additional information gets stored or recalled all I want is to when a user is created that they can specify business name allong with the standard user account information, how is this done, and is the info stored in the same database or what, I dont know just know this is what I want to do Help please anyone lee
The other way is if I use boomers sugestion which is great thank you, but when i creat a user how do i get the username to automaticly save to the main aspnet_user table as well as my custom table when the register button is clicked lee
Hey Lee To be honest Ive never used the built in .NET membership components, Ive always chosen to use my own structure for one reason or another... so I wouldnt be able to tell you for certain how to do this. I wouldve thought it would be possible to reference one of the textfields within the createusewizard - so it would just be a case of setting up another INSERT sql statement and inserting whatever if within the 'username' text field? - If its not as simple as this then let me know and I guess I could take a look around for you? Short of that I could send you an example of my own registration/login source... it would be easy to store the info in more that 1 table with my own registration system.
That would be great if you could send me that if you dont mined, mite take me a while to figure it out and may need your help if thats ok I dont need to use the bult in create user just though you had to to use autnetication lee
Ok i'll write something up along with comments to explain what everything does and upload it. Ive got the kids today so it'll be some point this evening
Another way to do it is to set the Continue Destination Page Url to say "newaccountsetup.aspx" then have code on the newaccountsetup page that inserts profile.username into the database. As long as primary keys and some validation is in place this works fine. I currently use it for this and to create their own folder on the server. Hope this helps! Ben
sorted it out and got it work thank god, I used the createuserwizard, converted it to template, added an extra textbox for school name and then in the on created user event add the code to recall the info from the extra textbox and the newly created user id and then save them using a table adapapter into my extra field database. The userid id then used to link to the membership database hwne details are recalled thanks everyone for your help anyone wnat to know more just ask lee