利用Properties-->Settings.settings保存信息

TextBox1.Text=global::网络中心计费系统.Properties.Settings.Default.radiusConnectionString;
这一句是显示类型为连接字符串的如:"server=210.38.240.251;user id=xinxi;database=radius;Password=051;persist security info=True"连接句柄的

 

ContractedBlock.gif ExpandedBlockStart.gif Code
namespace 网络中心计费系统
ExpandedBlockStart.gifContractedBlock.gif
{
    
public partial class Connection : Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
{
        网络中心计费系统.Properties.Settings 
set;
        
public Connection()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            InitializeComponent();
            
set = new 网络中心计费系统.Properties.Settings();
        }


        
        
private void Connection_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
           
//  this.textBox1.Text = global::网络中心计费系统.Properties.Settings.Default.ConnectionString;
           this.textBox1.Text = set.Sourcestring;
            
this.textBox2.Text = set.DataBase;
            
this.textBox3.Text = set.User;
        
            
this.textBox4.Text = set.Password;
            
        }


        
private void button1_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            MySQLConnection cn 
= new MySQLConnection(new MySQLConnectionString(this.textBox1.Text.ToString(), this.textBox2.Text.ToString(), this.textBox3.Text.ToString(), this.textBox4.Text.ToString()).AsString);

            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                cn.Open();
                MessageBox.Show(
"恭喜,测试连接成功""温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            
catch
ExpandedSubBlockStart.gifContractedSubBlock.gif            
{
                MessageBox.Show(
"很遗憾,测试连接失败,请检查""温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }


        
private void button2_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        

            
set.Sourcestring = this.textBox1.Text.ToString().Trim(); 
            
set.DataBase = this.textBox2.Text.ToString().Trim();
            
set.User = this.textBox3.Text.ToString().Trim();
            
set.Password = this.textBox4.Text.ToString().Trim();
            
set.Save();
            MessageBox.Show(
"更新成功!请重新运行程序!""温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Application.Exit(); 

        }


        
private void button3_Click(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
{
            Application.Exit(); 

        }



    }

}

转载于:https://www.cnblogs.com/linbohuang/archive/2008/11/27/1342295.html

你可能感兴趣的:(利用Properties-->Settings.settings保存信息)