Whenever the new user logs in to his registered account, at that time I need to create a table automatically for his account & it has to access the user name as the table name using C# coding. Because I want to add product details into cart like online shopping sites. If user login into their account what are the details available in the cart should display in their page.. is there is any other way to add product details into cart....
Asked
Active
Viewed 721 times
0
-
Are you sure you want to create a new table for each user? – Vidhyardhi Gorrepati Nov 29 '16 at 02:51
-
yaa sure....i want to create separate table....please help me how to create – Harini Nov 29 '16 at 03:02
-
well...in that case, create a SP which creates a table and call that SP from your code. – Vidhyardhi Gorrepati Nov 29 '16 at 03:07
-
but in that case, we cant pass user name as table name – Harini Nov 29 '16 at 03:12
-
http://stackoverflow.com/questions/1246760/how-should-i-pass-a-table-name-into-a-stored-proc – Vidhyardhi Gorrepati Nov 29 '16 at 03:25
2 Answers
3
You shouldn't create a new table for each user. Instead create a single user table where you store user-specific data (such as username, email, etc.). Then for any type of item that you want to associate with a user, such as purchase items, create a foreign key to the user table. You may want to read up on the basics of relational/SQL database design first.

Henning Koehler
- 2,456
- 1
- 16
- 20
-
-
when you say create table automatically are you talking about code first entity framework? http://www.entityframeworktutorial.net/code-first/entity-framework-code-first.aspx – Bryan Dellinger Nov 29 '16 at 04:03
0
Online shopping cart is the temporary data in the current user session, I think you don't need to create table to stored that data. You just create a session variable (DataTable) to stores data of online shopping cart.

Phạm Văn Huy
- 19
- 4