View Full Version : Storing Logged in Username in table of asp.net

08-17-2012, 12:32 PM

I'm developing a Customer online ordering system using asp.net.

I created two tables Users & Orders.
1. User table consists of the columns (UserId, Username, Password etc.)

2. Order Table COnsists of the columns (OrderId, Order name,UserId)

I link two tables the User Table and order Table by specifying UserId in the User table as Primary key and foreign key as UserId in Order table.

Once a normal User looged in to the system, he should be able to create his orders.

Once he create order, his logged in Username should be stored in the Order table for reporting purpose.

How can i make this?

Please guide me on this.

08-17-2012, 07:59 PM
assuming OrderId is an identity field...

insert into tblOrder ([OrderName], [UserId], etc...)
values ('someName', 5, etc)

5 is a random "UserId"

Narasimha Rao K
08-22-2012, 09:53 AM
when, first time user logged into the page,after enter his credentials,in submit button click event capture the user Id, then send it to the table, get the name of the user then insert into order tble .
insert into tblOrder ([OrderName], [UserId],[username])
values ('someName', 001,(User Name)).

09-12-2012, 06:03 PM

string UserId = System.Guid.NewGuid().ToString();
string OrderId= System.Guid.NewGuid().ToString();

insert into TableUser((UserId, Username, Password etc.)
insert into TableOrder(OrderId, Order name,UserId)