Click here to Skip to main content
15,666,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I am about to build a CUSTOMER MANAGEMENT SYSTEM as I call it.
I would greately a appreciate your help.

The plan is to create a web application where a person (business owner or self employed person) would log in and would be able to create, edit or delete customers, create reports, print reports and email invoices. No problem, I know how to do this.

My question is: What is the best way to manage each account.
A).- If to use one database for all users, or
B).- Assign to each one a database

I am totally ignorant about how other systems do it.

I would like to assign each a database, but how to supply a connection string to some of the SqlDataSource objects which would be hard-coded in to some of pages to be used to populate GridViews.

Please help me out here. Tell me how to do this or point me in the right direction.


First of all you shouldn't hard code anything.

You can do it with either one database or multiple, it really depends on your usage, security requirements, performance, plus other factors. Typically each customer would have a seperate database for security. Connection strings could stored in a central database, that way only one connection string is exposed.
Share this answer

You can use separate database for each account. So there will be no performance issue. You have to manage you connectionstring dynamically in this case. You can keep you virtual directory and database name same, so you can build your connectionstring from the VD name. Also you have to assign SQLDataSource from the code behind and use dynamic connectionstring.

Hope this will help :)

Share this answer
Member 4605756 29-Dec-11 23:11pm    
Thanks guys for answering my question.
Now Vinod, when you say use "dynamic connectionstring" you mean build the connectionstring from "SELECT dB_Name FROM DataBaseNames WHERE User_ID = @User_ID" and use this to build and supply the connection string on Page_Load event? Or what is another method?

Vinod Satapara 30-Dec-11 0:22am    
You can build connectionstring on Login page and store it in session. Use that connection string everywhere in project.
[no name] 30-Dec-11 23:39pm    
ridiculous, inefficient and unsecure. You should not be doing such tasks in the page load or anywhere in the presentation layer
[no name] 30-Dec-11 23:46pm    
You should have seperate layers for your application. All data access should done in that layer. At the most you pass an id for the client to this layer which obtains the proper connection string from a store, such as a database. As I said in my solution only one connection string is exposed, more secure and easier to maintain. Building the connection string dynamically may work for a small scale but will quickly become a headache later.
Member 4605756 30-Dec-11 8:24am    
Thanks Vinod.
I'll start my project and try to do what you say.
By the way, is there a code example, an open source project in C#, or a book that I can refer to for inspiration..?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900