TextBox1.Text=global::网络中心计费系统.Properties.Settings.Default.radiusConnectionString;
这一句是显示类型为连接字符串的如:"server=210.38.240.251;user id=xinxi;database=radius;Password=051;persist security info=True"连接句柄的
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
namespace 网络中心计费系统
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
public partial class Connection : Form
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
网络中心计费系统.Properties.Settings set;
public Connection()
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
InitializeComponent();
set = new 网络中心计费系统.Properties.Settings();
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void Connection_Load(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.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;
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void button1_Click(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MySQLConnection cn = new MySQLConnection(new MySQLConnectionString(this.textBox1.Text.ToString(), this.textBox2.Text.ToString(), this.textBox3.Text.ToString(), this.textBox4.Text.ToString()).AsString);
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
try
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
cn.Open();
MessageBox.Show("恭喜,测试连接成功", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
MessageBox.Show("很遗憾,测试连接失败,请检查", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void button2_Click(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.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();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
private void button3_Click(object sender, EventArgs e)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Application.Exit();
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}
}