Question : Working with multiple MS SQL Server database in applicatie

Hi,

Workflow:
1. User starts application.
If no DB is available then
begin
    A2. User gives name for the new database (f.e. "MyFirstDB")
    A3. Application will make a copy of an Empty DB and rename it to the given name "MyFirstDB".
    A4. Application will attach the database to MS SQL Server and create an UDL-file for easy future access (using the DB-name as name for the UDL-file "MyFirstDB.udl".
end else
begin
    B2. User can select from available DB's
      OR
    A2. + A3. + A4 (creating a new DB (f.e. "MySecondDB")
end;
C1. Application is started and connected (using udl-file) to the selected DB (f.e. "MyFirstDB").

Question:
Basically I need to find a way to present a list of available databases (that were created by my application).
f.e.:
"MyFirstDB"

"MySecondDB"


This information can't be stored in the DB (as I don't know which one will be opened), so I need to find some other way. To store the names and present them to select one of them.
Any suggestions, examples (best practice)?

Answer : Working with multiple MS SQL Server database in applicatie

the question contains a multitude of subquestions ...

1. A2
  --> is the mssql software installed locally ?
  --> on a server ?
1. A3
  --> copy ? why not use a script to create the database ?
  --> footprint of sql script is a lot smaller than a database copy
  --> look here:
    http://tgrignon.wordpress.com/2008/02/12/creating-a-sql-server-database-by-script/
    http://msdn.microsoft.com/en-us/library/aa258257%28SQL.80%29.aspx
1. A4
  --> udl file, basically a connection string
  --> if the software is in installed for that provider

1. B2
  --> find a list of available mssql databases:
  --> http://delphi.about.com/od/sqlservermsdeaccess/l/aa090704a.htm

Actual Question:
Basically I need to find a way to present a list of available databases (that were created by my application).
create a specific table in a specific schema
and then look for that table/schema
as an extra you could add a row in that table/schema with your specific company information

create table CompanyInfo (
  CompanyName varchar(100),
  Version varchar(20))

insert into CompanyInfo (CompanyName, Version) values ('YourCompany', '1')


Random Solutions  
 
programming4us programming4us