PetShop3已经自带了个加密解密的PetShop.Utility.dll,你利用这个PetShop.Utility.dll就可以生成数据库连接串PetShop2的数据库连接串是没有加密的

解决方案 »

  1.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using PetShop;
    using PetShop.Utility;namespace connstrForMSpetshop
    {
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.Windows.Forms.TextBox textBox2;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Required for Windows Form Designer support
    //
    InitializeComponent(); //
    // TODO: Add any constructor code after InitializeComponent call
    //
    } /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.textBox1 = new System.Windows.Forms.TextBox();
    this.button1 = new System.Windows.Forms.Button();
    this.button2 = new System.Windows.Forms.Button();
    this.textBox2 = new System.Windows.Forms.TextBox();
    this.SuspendLayout();
    // 
    // textBox1
    // 
    this.textBox1.Location = new System.Drawing.Point(8, 8);
    this.textBox1.Multiline = true;
    this.textBox1.Name = "textBox1";
    this.textBox1.Size = new System.Drawing.Size(480, 80);
    this.textBox1.TabIndex = 0;
    this.textBox1.Text = "";
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(496, 16);
    this.button1.Name = "button1";
    this.button1.TabIndex = 1;
    this.button1.Text = "加 密";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // button2
    // 
    this.button2.Location = new System.Drawing.Point(496, 64);
    this.button2.Name = "button2";
    this.button2.TabIndex = 2;
    this.button2.Text = "解 密";
    this.button2.Click += new System.EventHandler(this.button2_Click);
    // 
    // textBox2
    // 
    this.textBox2.Location = new System.Drawing.Point(8, 120);
    this.textBox2.Multiline = true;
    this.textBox2.Name = "textBox2";
    this.textBox2.Size = new System.Drawing.Size(480, 80);
    this.textBox2.TabIndex = 3;
    this.textBox2.Text = "";
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(584, 213);
    this.Controls.Add(this.textBox2);
    this.Controls.Add(this.button2);
    this.Controls.Add(this.button1);
    this.Controls.Add(this.textBox1);
    this.Name = "Form1";
    this.Text = "connstrForMSpetshop";
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } private void button2_Click(object sender, System.EventArgs e)
    {
    string temp=textBox1.Text.Trim();
    if(temp!="")
    {
    textBox2.Text=ConnectionInfo.DecryptDBConnectionString(temp);
    }
    } private void button1_Click(object sender, System.EventArgs e)
    {
    string temp=textBox1.Text.Trim();
    if(temp!="")
    {
    textBox2.Text=ConnectionInfo.EncryptDBConnectionString(temp);
    }
    }
    }
    }//还需要手工引用你的PetShop.Utility.dll文件
      

  2.   

    若有什么疑问,可通过MSN告诉我,my MSN:[email protected]
      

  3.   

    多谢eheartcool(ced)。
    我试一下先。我说错了,我用的demo是PetShop3.0
      

  4.   

    建议你引用你的PetShop.Utility.dll,然后建个WINFORM(象我提供的CODE那样),就很方便来对数据库连接串做加密解密了,GOOD LUCK
      

  5.   

    eheartcool(ced) 的建议不错,
    不知其它兄弟还有什么好的建议!
    欢迎各位评论
      

  6.   

    十分感谢eheartcool(ced)。
    散分!!