Last post Jun 27, 2014 03:30 PM by new2world
Jun 24, 2014 08:09 AM|new2world|LINK
I have made two signup forms, First one is by using createuserwizard and after filling the form it takes it to sign2 form where I have added extra things like first name lastname etc.
Now thing is I want to have one thing similar in both of the form so I was thinking userid would do this thing.
So how can I attach Userid of createuserwizard with my sign2 form so that everything store for a paritcular user.
Jun 24, 2014 08:39 AM|ClarkNK|LINK
Look at the tables in your aspnetdb.mdf database. You will find the UserID as the primary key in the Aspnet_Users table and how it is tied to other tables such as the aspnet_usersinroles table.
You need to do the same thing with your sign2 table -- you need the UserID to be a common key to the tables. This is normally done by setting up the Database Diagram.
Jun 24, 2014 11:38 AM|new2world|LINK
Here is the things that I am doing right now.
Set the primary key to Userid in custom table and set the relationship key with asp_ user table for userid.
Now when I create user in create user data get enter but for custom form I am getting this error when I remove userid from sql connection insert.
Error:System.Data.SqlClient.SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_User_Information_aspnet_Users"F
This is my created wizard user cs file :
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
MembershipUser newUser = Membership.GetUser(CreateUserWizard1.UserName);
Guid newUserId = (Guid)newUser.ProviderUserKey;
this code is in Custom table CS file :
protected void btnsubmit_Click(object sender, EventArgs e)
Guid id = Guid.NewGuid();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["userConnectionString"].ConnectionString);
string insertQuery = " insert into User_Information ( Userid, FirstName) Values( @Userid, @FirstName)";
SqlCommand com = new SqlCommand(insertQuery, conn);
Is there other way to have userid in my custom table cs file?
Kindly let me know thanks
Jun 26, 2014 02:22 AM|Terry Guo - MSFT|LINK
From your error message, I guess the Userid of your User_Information table have be constraint to User table as foreign key.
So, the Userid of User_Information value must fetch from User table.
Jun 26, 2014 09:04 AM|ClarkNK|LINK
New2World: You should set up your database diagram and User_Information table like so:
Your User_Information table should have UserID as primary key:
and you should set up the relationship for UserID in the database diagram:
Jun 27, 2014 03:30 PM|new2world|LINK
Thank you so much, I was able to make the form atlast.