Reputation: 139
Almost done with my C# Password Generator/Store. All the passwords are stored in a local encypted database that is hashed and also has a DB password. I am using sql express/compact(whatever it is called) to create the database manually. I was wondering if there was a way to check if a database was already created and has the right tables included. Also is there a way if the DB is not created to tell it to create an encrypted DB? Also have it create a folder in a speceific location too if that is not there also create it and store the DB inside.
Thanks
Upvotes: 2
Views: 1993
Reputation: 10115
I was wondering if there was a way to check if a database was already created
Select * from sys.databases Where name = 'YourDatabaseName'
Alternative
Select * from sys.objects Where name = 'YourDatabaseName'
has the right tables included
Select * from sys.tables where name = 'YourTableName'
Alternative
Select * from sys.objects where name = 'YourTableName'
Also is there a way if the DB is not created to tell it to create an encrypted DB?
If Not Exists(Select * from sys.databases Where name = 'YourDatabaseName')
Begin
--Create your database
End
Folder creation is the process during the database creation
Upvotes: 1
Reputation: 109037
You can run a query like this
IF NOT EXISTS
( SELECT [name]
FROM sys.tables
WHERE [name] = 'TableName`
)
CREATE TABLE TableName (Col1 int, Col2 int ... )
for each table in the right order.
Upvotes: 2