Re: Detect if db is empty
- From: bz <bzamfir@xxxxxxxxx>
- Date: Thu, 13 Aug 2009 11:31:09 -0700 (PDT)
Hi,
I already check for dbversion table and its structure, and if ok,
proceed with db structure update, otherwise I report db as not
compatible
Now I submit with the app a simple script that create db,
DBVersionTable and user to access the DB, which user must run in ent
manager.
I was planning to just ask user to create db only, by himself, and
then ask user to enter db name and app will check if db is new and
create dbver and all other things
And my test was to make sure uyser don't enter by mistake the name of
another db, with objects in it
But it seems I have to stick with my current approach, as it seems
more reliable
Thanks for all answers and suggestions
On 27 iul., 18:08, "John Bell" <jbellnewspo...@xxxxxxxxxxx> wrote:
"bz" <bzam...@xxxxxxxxx> wrote in message
news:5882aa24-bbff-4c33-8286-85b7d14a1375@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Why not check for the existance of the database and drop it or tell the
user
to enter a different name? Then you can create the database yourself and
it
will be empty.
I don't want to drop the db.
Actually, I need this for a code who runs on a web app (asp.net), to
allow to update db structure
What I planned was, when user install the app for the first time, he
will also have to create an empty DB, and a user with ddl_admin rights
(or, assign ddl_admin rights to asp.net / networkservice)
Then set the connection string in web.config to use this db and this
user (or trusted connection if using asp.net)
Then the app will connect to db. If empty, it will start to create it
(by creating first a DbVersion table, which will keep track of all
incremental updates. Then it will run a batch of DDL scripts to update
db structure to latest version used in development.
If db is not empty (brand new) and also don't have the proper
DbVersion file, app will not do anything on the db.
If prev. ver of app was installed, a prev version of db will be
available too, app will detect this (based on dbVersion table) and
will apply only corresponding update steps.
I cannot drop db, since I need to preserve user data.
Thanks
Bogdan
If sounds like the existance of your version table is all that you are
really bothered about to test if you need the intitial installation.
If the version table exists then you check the version number. If no version
exists an installation has failed.
John
.
- Follow-Ups:
- Re: Detect if db is empty
- From: John Bell
- Re: Detect if db is empty
- Prev by Date: cannot install SQL 2005 Standard SP3
- Next by Date: Re: Detect if db is empty
- Previous by thread: Re: Detect if db is empty
- Next by thread: Re: Detect if db is empty
- Index(es):
Relevant Pages
|