求救!登陆窗口连接不上数据库,commandtext does not return a result set
一个身份验证的登陆窗口。报错:adoqry:commandtext does not return a result set
快被纠结死了。。
void __fastcall TLogForm::BitBtn1Click(TObject *Sender)
{
if(account->Text==""||password->Text=="")
{
MessageBox(NULL,"用户名和密码不能为空!","提示",MB_OK);
return;
}
String ac=Trim(account->Text);
String pw=Trim(account->Text);
String sql;
sql.Format("select * from Core_User where U_No='%s' and Password='%s'",
ARRAYOFCONST((account->Text,password->Text)));
adoqry->SQL->Clear();
adoqry->Close();
adoqry->SQL->Add(sql);
adoqry->ExecSQL();
adoqry->Active=true;
if(adoqry->RecordCount>0)
{
//生成主窗口代码,还没写
return;
}
else
{
MessageBox(NULL,"用户名不存在或密码错误!","提示",MB_OK);
return;
}
}
[解决办法]
adoquery->Open()
select 语句用open,insert delete update用ExecSQL
[解决办法]
adoqry->ExecSQL();
改成
adoqry->Open();
[解决办法]
adoqry->Open();
//adoqry->Active=true;去掉这句
[解决办法]
adoqry->Close();
adoqry->SQL->Clear();--先Close,再clear,调整顺序
adoqry->SQL->Add(sql);
adoqry->Open();