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