Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I deveploped windows application Using VB.net and SQL2005

I had tables in the database as

Company,Customer,Supplier,Purchase,Sales tables...

I need help for do the following work.....

When the user create one new company, separate database want to create at the name of company,,,, data of the particular company want to store in it's database.....



Give idea for this.........


Posted

1 solution

You have to create databases as needed, or create a whole new layer in your DB, so that one DB can hold data for many companies. Or do you mean how do you DISTRIBUTE a DB with your installer ? Using SQL Server lite edition makes the most sense, as it is free.

CREATE TABLE
COMPANY
begin
id int identity(1,1),
name nvarchar(200),
username nvarchar(200),
password nvarchar(200)
end

I'd have usernames in another table, so there could be many for one company, but, the point is, company.id is now added as an identifier to your current top level tables, and then any data below that, maps back through the middle table so it is also associated with a company. Now your app needs to require a DB login, which will mean any data it creates or uses, will only be visible to users from that company.

This is all assuming you have ONE DB server, that all these DIFFERENT companies will use.
 
Share this answer
 
v2
Comments
PunithaSabareeswari 29-Jul-12 1:35am    
hi... Thanks for ur idea.... but i want to some depth knowledge in this.. can u give...
i'm learner of database.... that's why i needed clear info for this... plz...
Christian Graus 29-Jul-12 1:38am    
I think it's not clear what you want. You want each user of your app to set up their own copy of your database to connect to, and each DB will be on a different server/network, right ? So, it's really a deployment issue ? I would give people SQL Server Lite Edition ( or whatever they call it now, the free one ). Then I'd expose a way to set the connection string in the app, but give it a sensible default. Then I'd add code in the program that can build a new database, such as shipping the SQL needed to do it, so you can connect and create an empty DB if needed.

Is that the sort of thing you need ?
PunithaSabareeswari 29-Jul-12 1:47am    
ya... correct man... all databases want to store in the server system of LAN network...
Christian Graus 29-Jul-12 1:50am    
OK, so they will all be on the same server ? In that case, it's probably easier to build your system so that you have one higher level, of company names, then every other bit of data links back to the company id, so each company can only see their own data.
PunithaSabareeswari 29-Jul-12 1:55am    
i think u got my needs.... when i want to do this all while creating company or else...

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