利用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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值