System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
System.Windows.Forms.Timer timer2 = new System.Windows.Forms.Timer();

SqlConnectionStringBuilder sqlb01 = new SqlConnectionStringBuilder();

sqlb01.DataSource = strdata;

sqlb01.InitialCatalog = "random";
sqlb01.UserID = strsa;
sqlb01.Password = strpwd;
sqlb01.IntegratedSecurity = false;
sqlb01.Pooling = true;
SqlConnection conn01 = new SqlConnection();
conn01.ConnectionString = sqlb01.ConnectionString;

// MessageBox.Show(strdata + "11" + strsa + "12" + strpwd);

try
{
conn01.Open();
if (conn01.State.ToString() == "Open")
{
label3.Text = "数据库链接成功";

timer2.Start();
timer2.Interval = 100;
timer2.Tick += new EventHandler(callback2);//计时器绑定事件
tz.Visible = true;

conn01.Close();
}

}

catch (SqlException sqlex)
{
MessageBox.Show("数据库配置错误,请重新填写/n");
label3.Text = "数据库链接失败";
tz.Visible = false;
conn01.Close();
}

posted on 2024-04-20 22:30  Lionever  阅读(9)  评论(0编辑  收藏  举报