-
June 22nd, 2011, 05:57 PM
#1
Problem with added table in App data Db ASPNETDB.MDF
I am new to C#, ASP.NET, SQL, and LINQ. I am a complete novice trying to find a way to finish my first Web app. I added a table to the ASPNETDB.MDF. I named it User_Signup. I added the fields: UserId, FirstName, LastName, Address1, Address2, City, ZipCode, State, TermsCheckBox, PrivacyCheckBox, BotEmailsCheckBox, PartnerEmailsCheckBox. I did types of nvarchar(50) for all but State, UserId and the check boxes. I did nvarchar(20) for State. I did bit for the check boxes and uniqueidentifier for UserId. Also State is a DropDownList not a TextBox. I added a relationship between the aspnet_Users table and my new User_Signup table. The aspnet_Users UserId is the primary key and the UserId in User_Signup is the foreign key.
I then wrote the following code on my page:
Code:
<asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="./SQLExpress;AttachDbFilename=C:\USERS\MIKEJR76\DOCUMENTS\VISUAL STUDIO 2010\PROJECTS\THECOUPONBOT.COM\THECOUPONBOT.COM\APP_DATA\ASPNETDB.MDF;Integrated Security=true;"
InsertCommand="INSERT INTO [User_Signup] ([UserId], [Firstname], [Lastname], [Address1], [Address2], [City], [Zipcode], [State], [TermsCheckbox], [PrivacyCheckbox], [BotEmailsCheckbox], [PartnerEmailsCheckbox]) VALUES
(@UserId, @Firstname, @Lastnam], @Address1, @Address2, @City, @Zipcode, @State, @TermsCheckbox, @PrivacyCheckbox, @BotEmailsCheckbox, @PartnerEmailsCheckbox)"
ProviderName="System.Data.SqlClient">
<InsertParameters>
<asp:ControlParameter Name="Firstname" Type="String" ControlID="FnTxtBox" PropertyName="Text" />
<asp:ControlParameter Name="Lastname" Type="String" ControlID="LnTxtBox" PropertyName="Text" />
<asp:ControlParameter Name="Address1" Type="String" ControlID="Add1TxtBox" PropertyName="Text" />
<asp:ControlParameter Name="Address2" Type="String" ControlID="Add2TxtBox" PropertyName="Text" />
<asp:ControlParameter Name="City" Type="String" ControlID="CityTxtBox" PropertyName="Text" />
<asp:ControlParameter Name="Zipcode" Type="String" ControlID="ZctxtBox" PropertyName="Text" />
<asp:ControlParameter Name="State" Type="String" ControlID="StateDropDown" PropertyName="Text" />
<asp:ControlParameter Name="TermsCheckbox" Type="Boolean" ControlID="CheckBox1" PropertyName="Boolean" />
<asp:ControlParameter Name="PrivacyCheckbox" Type="Boolean" ControlID="CheckBox2" PropertyName="Boolean" />
<asp:ControlParameter Name="BotEmailsCheckbox" Type="Boolean" ControlID="CheckBox3" PropertyName="Boolean" />
<asp:ControlParameter Name="PartnerEmailsCheckbox" Type="Boolean" ControlID="CheckBox4" PropertyName="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
Here is my event handler in the code behind:
Code:
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
TextBox UserNameTextBox = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName");
SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep1.ContentTemplateContainer.FindControl("InsertExtraInfo");
MembershipUser User = Membership.GetUser(UserNameTextBox.Text);
object UserGUID = User.ProviderUserKey;
DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
DataSource.Insert();
It compiles and runs. It creates the new user and updates the aspnet_Users table but it doesn't update my User_Signup table. I have been over it a thousand times and can't figure out what I did wrong. I have searched a ton of forums and 2 reference books. but I am stuck.Please Help!
Also one added question. When I deploy to my web server. Will the connection string be the same except the server name?
Thank you in advance!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|