单击确定按钮登录
代码:
string sql = string.Format("select M_Pwd,M_Power from Manager where M_Name='{0}'", textBox1.Text);
oleDbConnection1.Open();
OleDbCommand cmd = new OleDbCommand(sql, oleDbConnection1);
OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
bool accept=false;
while(dr.Read())
{
if(dr.GetString( 0).Trim( )==textBox2 .Text )
{
accept=true;
button1.DialogResult = DialogResult.OK;
}
}
dr.Close();
if(accept ==false)
{
MessageBox.Show("登录失败");
}
怎么样按一次就能登录进去那?请教高手~在这里先谢谢了
代码:
string sql = string.Format("select M_Pwd,M_Power from Manager where M_Name='{0}'", textBox1.Text);
oleDbConnection1.Open();
OleDbCommand cmd = new OleDbCommand(sql, oleDbConnection1);
OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
bool accept=false;
while(dr.Read())
{
if(dr.GetString( 0).Trim( )==textBox2 .Text )
{
accept=true;
button1.DialogResult = DialogResult.OK;
}
}
dr.Close();
if(accept ==false)
{
MessageBox.Show("登录失败");
}
怎么样按一次就能登录进去那?请教高手~在这里先谢谢了
改成this.DialogResult = DialogResult.OK;行不行?
谢谢你们俩.把button1.DialogResult = DialogResult.OK;改称
this.
就好使了.
ps:鱼
结束代码我写了.是在窗体启动的地方写的.
http://blog.csdn.net/knight94/archive/2006/04/06/652394.aspx