测试连接:为何连接成功,FrmMain的Text没改变?
主窗体是FrmMain ,登录窗体是FrmLogin
为何连接成功,FrmMain的Text没改变?
代码是:
string ConnectStr = "server=localhost;database=ClassDesign;uid=sa;pwd=;";
try
{
SqlConnection mycon = new SqlConnection(ConnectStr);
mycon.Open();
FrmMain frmmain = new FrmMain();
frmmain.Text = frmmain.Text + "—已登录";
MessageBox.Show("连接成功");
this.Hide();
}
catch
{
MessageBox.Show("连接失败","连接出错");
return;
}
大家多多指点~~