检查本地数据库是否已创建 C#

发布于 2024-11-09 11:59:12 字数 214 浏览 0 评论 0原文

我的 C# 密码生成器/存储区即将完成。所有密码都存储在本地加密数据库中,该数据库经过哈希处理,并且还具有数据库密码。我正在使用 sql express/compact(无论它叫什么)手动创建数据库。我想知道是否有一种方法可以检查数据库是否已创建并且包含正确的表。如果未创建数据库,是否有办法告诉它创建加密数据库?如果不存在,也可以在特定位置创建一个文件夹,也可以创建它并将数据库存储在其中。

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

留蓝 2024-11-16 11:59:12

运行这样的查询。

  IF NOT EXISTS
   (  SELECT [name] 
      FROM sys.tables
      WHERE [name] = 'TableName`
   )
   CREATE TABLE TableName (Col1 int, Col2 int ... )

您可以按正确的顺序对每个表

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.

倾城月光淡如水﹏ 2024-11-16 11:59:12

我想知道是否有办法
检查数据库是否已经存在
已创建

Select * from sys.databases Where name = 'YourDatabaseName'

替代方案

Select * from sys.objects Where name = 'YourDatabaseName'

包含正确的表格

Select * from sys.tables where name = 'YourTableName'

表格

Select * from sys.objects where name = 'YourTableName'

如果数据库不存在,还有什么办法吗?
创建告诉它创建一个
加密数据库?

If Not Exists(Select * from sys.databases Where name = 'YourDatabaseName')
Begin
    --Create your database
End

文件夹创建是数据库创建过程中的过程

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文