sql >> データベース >  >> RDS >> Sqlserver

データベースの既存のすべてのストアドプロシージャを暗号化する方法

    すべての暗号化を確認することをお勧めしますデータベースのストアドプロシージャ

    //Connect to the local, default instance of SQL Server. 
    string DB = "";
    ServerConnection objServerCOnnection = new ServerConnection();
    objServerCOnnection.LoginSecure = false;
    Console.WriteLine("Enter name or IP Address of the Database Server.");
    objServerCOnnection.ServerInstance = Console.ReadLine();
    Console.WriteLine("Enter name of the Database");
    DB = Console.ReadLine();
    Console.WriteLine("Enter user id");
    objServerCOnnection.Login = Console.ReadLine();
    Console.WriteLine("Enter Password");
    objServerCOnnection.Password = Console.ReadLine();
    Console.WriteLine(" ");
    Server srv = new Server();
    try // Check to see if server connection details are ok.
    {
       srv = new Server(objServerCOnnection);
       if (srv == null)
       {
          Console.WriteLine("Server details entered are wrong,"
             + " Please restart the application");
          Console.ReadLine();
          System.Environment.Exit(System.Environment.ExitCode);
       }
    }
    catch
    {
       Console.WriteLine("Server details entered are wrong,"
          + " Please restart the application");
       Console.ReadLine();
       System.Environment.Exit(System.Environment.ExitCode);
    }
    Database db = new Database();
    try // Check to see if database exists.
    {
       db = srv.Databases[DB];
       if (db == null)
       {
          Console.WriteLine("Database does not exist on the current server,"
             + " Please restart the application");
          Console.ReadLine();
          System.Environment.Exit(System.Environment.ExitCode);
       }
    }
    catch
    {
       Console.WriteLine("Database does not exist on the current server,"
          + " Please restart the application");
       Console.ReadLine();
       System.Environment.Exit(System.Environment.ExitCode);
    }
    string allSP = "";
                    
    for (int i = 0; i < db.StoredProcedures.Count; i++)
    {
       //Define a StoredProcedure object variable by supplying the parent database 
       //and name arguments in the constructor. 
       StoredProcedure sp;
       sp = new StoredProcedure();
       sp = db.StoredProcedures[i];
       if (!sp.IsSystemObject)// Exclude System stored procedures
       {
          if (!sp.IsEncrypted) // Exclude already encrypted stored procedures
          {
             string text = "";// = sp.TextBody;
             sp.TextMode = false;
             sp.IsEncrypted = true;
             sp.TextMode = true;
             sp.Alter();
     
             Console.WriteLine(sp.Name); // display name of the encrypted SP.
             sp = null;
             text = null;
          }
       }
    }
    


    1. モデルで使用されているLaravelの生のDBクエリにパラメーターをバインドするにはどうすればよいですか?

    2. 辞書を使用してパラメーターをPythonのpostgresqlステートメントに渡す

    3. mysqlで、結合する行の数を制限します

    4. NULL値で正しく機能するpostgresqlの最初と最後の値の集計関数