Tuesday, May 8, 2012

SQL for Getting Registered Customer Information

For Your ASP/ADO assignment: After you log in your will want to return some customer information on the next web page. You have the customer's email saved in the Session variable. You can use it to get the Customer information. Here is a SQL string you can use:


SELECT LastName, FirstName, Email, VehicleID, VehicleMake, VehicleYear
FROM Person p
INNER JOIN Customer.Vehicle v
ON p.PersonKey=v.PersonKey
INNER JOIN Customer.RegisteredCustomer rc
ON p.PersonKey=rc.PersonKey
WHERE Email = @email

You will need to resolve the variable @email with the parameters in the command object. First get the value from the Session variable than use the addwithvalue method of the parameter


string email = Session["user"].ToString();
. . .

cmd.Parameters.AddWithValue("@email", email);

I also retrieved the VehicleID, because you can use it to get the vehicle service information

No comments:

Post a Comment