0

我可以在 sql 命令之后从 sql server 执行创建这个,但是有没有办法使用 C# 代码执行这个命令?

sql命令...

USE master;
    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'rajesh';
Go

Use Master
    BACKUP MASTER KEY TO FILE = 'C:\Users\HP USER\Desktop\Encrypt\KEYs' 
    ENCRYPTION BY PASSWORD = 'rajesh'
GO 

Use Master
      CREATE CERTIFICATE mytestcert
      WITH SUBJECT = 'Mytestcertificate'

Use Master
    BACKUP CERTIFICATE mytestcert TO FILE = 'C:\Users\HP USER\Desktop\Encrypt\mytestcert.cer'
GO

CREATE DATABASE dbShop ;
GO  

USE dbShop
GO
CREATE DATABASE ENCRYPTION KEY 
  WITH ALGORITHM = AES_256
  ENCRYPTION BY SERVER CERTIFICATE [mytestcert]
ALTER DATABASE test
  SET ENCRYPTION ON;
4

1 回答 1

0

您可以将命令放在存储过程中,然后从 C# 执行存储过程。

于 2013-10-18T13:58:52.513 回答