Wrox Programmer Forums
|
BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9
This is the forum to discuss the Wrox book Professional ASP.NET 3.5: In C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470187579
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 1st, 2009, 08:12 PM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert data using LINQ SQL - page 471

Greetings - I used the code on page 471 to insert data using a stored procedure. I am trying to insert into 3 tables. The code works, but it only inserts data into the first table (Member). It creates a record in the other two tables (MemberCompany and MemberDemographic) with an ID that matches the first table (Member), but does not insert the data (the fields are NULL). I would appreciate any help to correct this - thanks!

Code:
 
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) Handles finish.ServerClick
 
Dim dc AsNew MemberDataClassesDataContext()
 
Dim mobjMember AsNew Member With {.FirstName = Trim(FirstName.Value), _
.LastName = Trim(LastName.Value), _
.GenderID = Trim(rblGender.SelectedItem.Value), _
.Address = Trim(Address.Value), _
.City = Trim(City.Value), _
.State = Trim(State.Value), _
.ZipCode = Trim(ZipCode.Value), _
.PhoneNumber = Trim(PhoneNumber.Value), _
.EmailAddress = Trim(EmailAddress.Value), _
.MembershipTypeID = Trim(rblMembershipType.SelectedItem.Value), _
.SendMailTypeID = Trim(rblSendMailTo.SelectedItem.Value), _
.SendEmailTypeID = Trim(rblSendEmailTo.SelectedItem.Value), _
.ReferredBy = Trim(ReferredBy.Value), _
.DateTime = Today(), _
.RegistrationDate = Today(), _
.ShareInformation = (chkShareInformation.Checked)}
 
'Set member company properties.
Dim MemberCompany AsNew MemberCompany With {.CoName = Trim(CoName.Value), _
.JobTitle = Trim(JobTitle.Value), _
.CoAddress = Trim(CoAddress.Value), _
.CoCity = Trim(CoCity.Value), _
.CoState = Trim(CoState.Value), _
.CoZipCode = Trim(CoZipCode.Value), _
.CoPhoneNumber = Trim(CoPhoneNumber.Value), _
.CoEmailAddress = Trim(CoEmailAddress.Value)}
 
'Set member demographic properties.
Dim MemberDemographic AsNew MemberDemographic With {.EducationLevel = Trim(rblEducationLevel.SelectedItem.Value), _
.WorkedInTechnology = Trim(rblWorkedInTechnology.SelectedItem.Value), _
.Degrees = Trim(rblDegrees.SelectedItem.Value)}
 
dc.Members.InsertOnSubmit(mobjMember)
dc.SubmitChanges()
Response.Redirect("PayJoin.aspx")
EndSub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Row Insert using Linq arivarasuk ASP.NET 3.5 Professionals 1 January 9th, 2009 11:21 AM
confusing in ADO.NET Entity Data Model,Linq to sql angelboy ADO.NET 5 November 21st, 2008 05:01 PM
INSERT Data to SQL Database Lofa ASP.NET 1.0 and 1.1 Basics 1 February 22nd, 2006 03:09 AM
Check before insert data into sql Alcapone C# 2 October 26th, 2004 07:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.