解决方案 »
- 【求助重绘问题】其他窗口移到我的对话框上时,对话框中的重绘控件花了
- 为什么 rundll32.exe 无法传递参数
- ~~~~~~~~~~~根据一个BMP图片文件,怎么样生成一个HBITMAP对象??????
- 有没有一些通用的数据库访问库
- vc6中做xp界面有比较好的工具吗?
- 新手求教简单问题:两台机器间的实时数据通讯问题的思路问题.
- MFC简单的位图变换操作求教!!
- 怎样用MFC程序自动点击网页上的按钮,浏览网页(高分求教解决方案,还可以加分)
- 我的MDI工程,能把VC自带的“帮助”这项菜单去掉么?
- 那位大虾知道怎样求nt 或 win2000的数据流量,类似win2000中的那个东西
- CButtonST类关联了一个按钮控件,但是按钮上的文字没了!
- 请问mfc里怎样完全隐藏鼠标
{
// TODO: Add your control notification handler code here
CString username,password;//字符串来用记录输入的用户名和密码
GetDlgItem(IDC_USER)->GetWindowText(username);//获取用户名
GetDlgItem(IDC_PASSWORD)->GetWindowText(password);//获取密码
if(username.IsEmpty()||password.IsEmpty())//判断用户名或密码是否为空
{
MessageBox("密码或用户名不能为空!!!");//若为空,显示"密码或用户名不能为空!!!"
}
{
CString sql;//字符串用来存储sql语句
CClassManageSysApp *App ;//CWinApp对象的指针 sql.Format("select * from UserInfo where [username] = '%s' and [password] = '%s'",username ,password);//sql语句
App = (CClassManageSysApp*)AfxGetApp();//返回指向应用程序的单一的CWinApp对象的指针
App->m_data.m_pRecordset->CursorLocation = adUseServer ;//设置记录集游标属性
App->m_data.m_pRecordset->Open((_bstr_t)sql,App->m_data.m_pConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,0);
//打开记录集
if(App->m_data.m_pRecordset->RecordCount>0)//判断记录集是否存在记录
{
try
{
CString str= (char*) (_bstr_t)App->m_data.m_pRecordset->GetFields()->GetItem("username")->Value;//读取记录集中读取数据
App->m_data.m_pRecordset->Close();//关闭记录集
}
catch (...)//捕捉异常,
{
MessageBox("用户名或密码不正确!!!");//显示 “用户名或密码不正确!!!”
App->m_data.m_pRecordset->Close();//关闭记录集
return ;
}
EndDialog(IDOK);//关闭登陆对话框
}
else
{
App->m_data.m_pRecordset->Close();//关闭记录集
MessageBox("用户名或密码不正确!!!");//显示 “用户名或密码不正确!!!”
}
}
}