View Single Post
  #10 (permalink)  
Old November 27th, 2006, 04:53 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi Peter,

The column CustomerId in the table OrderBase is the user's ID from the aspnet_Users table. You can use this ID to find specific orders (and their details) for a user. You can get at the user's ID with the following code:
Dim myUser As MembershipUser = Membership.GetUser()
Dim userId As Guid = CType(myUser.ProviderUserKey, Guid)
You can then pass this ID into the DAL and forward it to a stored procedure that queries the orders for a user like this:
SELECT     Id, OrderDate, CustomerId, FirstName, LastName, Street, ZipCode, City, Country
FROM         OrderBase
WHERE     (CustomerId = @userId)
You can join the OrderBase table on the OrderDetail table to get related order info.

Don't forget that Membership.GetUser() only returns a valid user when the current user is logged in.

Does this put you in the right direction?

Is this shop live somewhere on the Internet? Would love to see how it is used....


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.