由于项目要求,在web.config中,数据库的链接配置connectionstring不允许password以明文的方式出现,所以在password中加了密。但我们使用了ms report(rdlc)报表工具,就会建立一个dataset,在dataset配置中,就会选择使用web.config当中配置的connectionstring,这样就造成了数据集中,任何datatableadapter都是无法登陆到数据库中的。
请问各位,有没有什么好的建议,能够达到以上要求?

解决方案 »

  1.   

    web.config 使用密文,取出来解密使用就好了...没有明白楼主要达到什么要求
      

  2.   

    base64加密 取出来的时候 解密后赋给sqconnection就可以了 
      

  3.   

    你dataset数据集控件 不是用代码绑定的么?
      

  4.   

    用的时候  在报表控件上绑定下不行么?像这样localReport.DataSources.Add(new ReportDataSource("Accient_DataSet_dt",dt);
      

  5.   

    private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
      /// DES加密字符串
      public static string Encrypt(string encryptString, string encryptKey)
      {
      try
      {
      byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
      byte[] rgbIV = Keys;
      byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
      DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
      MemoryStream mStream = new MemoryStream();
      CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
      cStream.Write(inputByteArray, 0, inputByteArray.Length);
      cStream.FlushFinalBlock();
      return Convert.ToBase64String(mStream.ToArray());
      }
      catch
      {
      return encryptString;
      }
      }
      /// DES解密字符串
      public static string Decrypt(string decryptString, string decryptKey)
      {
      try
      {
      byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey);
      byte[] rgbIV = Keys;
      byte[] inputByteArray = Convert.FromBase64String(decryptString);
      DESCryptoServiceProvider DCSP = new DESCryptoServiceProvider();
      MemoryStream mStream = new MemoryStream();
      CryptoStream cStream = new CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
      cStream.Write(inputByteArray, 0, inputByteArray.Length);
      cStream.FlushFinalBlock();
      return Encoding.UTF8.GetString(mStream.ToArray());
      }
      catch
      {
      return decryptString;
      }
      }
    aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"   
    XP下:aspnet_regiis -pa "NetFrameworkConfigurationKey" "aspnet"   
    加密:aspnet_regiis -pe "appSettings" -app "/应用程序名 "   
    解密:aspnet_regiis -pd "appSettings" -app "/应用程序名   RDLC绑定数据集