解决方案 »
- 到底什么是什么是"win32子系统"?
- 去除网页图片
- 如何做一个透明的视图..
- [钩子高手请进] 我在全局钩子中得到了某窗体的指针,pWnd,我将它转换为窗体源码中对应的窗口类:(CMyWnd *),可以通过这个指针访问CMyWnd窗口类的成员吗?怎么弄?多谢~!
- 大家帮我看看,为什么服务端收不到数据?
- delphi開發的DLL被VC調用中的問題
- sql2000一个存储过程
- 新人求助,使用mscomm做的一个MFC通信程序放到别的电脑打不开
- Ado 访问数据库,我如果把程序装到其它的机子,这台机子的ADO与我的机子不是在同一个目录程序可以正常运行吗
- 关于ActiveX与网页的结合问题
- 熟悉Direct3D的朋友,请教
- 求教:MFC的控件问题
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_number.IsEmpty()||m_password.IsEmpty())
AfxMessageBox("学号和密码都不能为空!");
else
{
AdoConn.OnInitADOConn();
CString strSQL="select count(*) as A from studentinfo where ID='"+m_number+"' and name='"+m_name+"'";
AfxMessageBox(strSQL);
_bstr_t bstrSQL(strSQL);
_RecordsetPtr precordset=AdoConn.GetRecordSet(bstrSQL);//获取记录
if((long)(m_pRecordset->GetCollect("A"))>0 ) {
flag=1;
this->EndDialog(1);
}
else
{
AfxMessageBox("学号或者密码错误!");
m_number=" ";
m_password=" ";
UpdateData(FALSE);
}
}
}
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_number.IsEmpty()||m_password.IsEmpty())
AfxMessageBox("学号和密码都不能为空!");
else
{
AdoConn.OnInitADOConn();
CString strSQL="select count(*) as A from studentinfo where ID='"+m_number+"' and name='"+m_name+"'";
AfxMessageBox(strSQL);
_bstr_t bstrSQL(strSQL);
_RecordsetPtr precordset=AdoConn.GetRecordSet(bstrSQL);//获取记录
if((long)(m_pRecordset->GetCollect("A"))>0 ) {
flag=1;
this->EndDialog(1);
}
else
{
AfxMessageBox("学号或者密码错误!");
m_number=" ";
m_password=" ";
UpdateData(FALSE);
}
}
}
m_rs->RecordCount 看是否等于0.如果是0就不存在,不在就有记录
CString strSQL="select * from studentinfo where ID='"+m_number+"' and name='"+m_name+"'";
我试了上面的方法,都没有成功。
这句话有问题吗?
precordset->RecordCount>0 也不能登录成功。
void CLoginDlg::OnLogin()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_number.IsEmpty()||m_password.IsEmpty())
AfxMessageBox("学号和密码都不能为空!");
else
{
AdoConn.OnInitADOConn();
CString strSQL="select * from studentinfo where ID='"+m_number+"' and name='"+m_name+"'";
AfxMessageBox(strSQL);
_bstr_t bstrSQL(strSQL);
_RecordsetPtr precordset=AdoConn.GetRecordSet(bstrSQL);//获取记录
if(!precordset->IsEOF())
{
flag=1;
this->EndDialog(1);
}
else
{
AfxMessageBox("学号或者密码错误!");
m_number=" ";
m_password=" ";
UpdateData(FALSE);
}
}
}
提示IsEOF' : is not a member of '_Recordset'
//下面GetRecordSet()函数的实现
_RecordsetPtr & CAdoConnection::GetRecordSet(_bstr_t bstrSQL) //执行查询
{
try
{
//连接数据库 如果Connection对象为空则重新连接数据库
if(m_pConnection==NULL)
OnInitADOConn();
//创建记录集对象
m_pRecordset.CreateInstance(__uuidof(Recordset));
//取得表中的记录
m_pRecordset->Open(bstrSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockBatchOptimistic,adCmdText);
}
catch (_com_error e)
{
//异常 显示错误信息
AfxMessageBox(e.Description());
}
return m_pRecordset;
}
_bstr_t bstrSQL(strSQL);
_RecordsetPtr precordset=AdoConn.GetRecordSet(bstrSQL);//获取记录
precordset->MoveFirst();
if(!precordset->IsEOF())
{
flag=1;
this->EndDialog(1);
}
//改成这样就可以了,大家帮忙解释下吧。
if(long(precordset->GetCollect(long(0)))>0)
{
flag=1;
this->EndDialog(1);
}
这是为什么呢?