数据库及界面跳转携带变量
2014-03-29 20:42
323 查看
UpdateData(); CoInitialize(NULL); _ConnectionPtr pConn(__uuidof(Connection)); _RecordsetPtr pRst(__uuidof(Recordset)); pConn->ConnectionString ="Provider=SQLOLEDB.1;Password=12345sa12345;Persist Security Info=True;User ID=sa;Initial Catalog=DBLAB;Data Source=STAR-PC;"; pConn->Open ("","","",adConnectUnspecified); //cstring.format CString str = "select * from dbo.userinfo where userName = '"; str += m_name; str += "' and userPwd = '"; str += m_pw; str += "'"; //_bstr_t pipei = (_bstr_t)str; //pRst=pConn->Execute(pipei,NULL,adCmdText); pRst=pConn->Execute((_bstr_t)str,NULL,adCmdText); if(!pRst->rsEOF)//pRst->rsEOF的值判定是否到达结尾,到达则为真,未到达则为假 { CDialog::OnOK(); CIndex dlg; dlg.m_whose = "当前登录用户为:" + m_name; dlg.DoModal(); } else MessageBox("登录失败!"); pRst->Close(); pConn->Close(); pRst.Release(); pConn.Release(); CoUninitialize();
涉及取SQL的内容,如下:
CoInitialize(NULL); _ConnectionPtr pConn(__uuidof(Connection)); _RecordsetPtr pRst(__uuidof(Recordset)); pConn->ConnectionString ="Provider=SQLOLEDB.1;Password=12345sa12345;Persist Security Info=True;User ID=sa;Initial Catalog=TestData1;Data Source=localhost;"; pConn->Open ("","","",adConnectUnspecified); pRst=pConn->Execute("select * from dbo.Products ",NULL,adCmdText); while(!pRst->rsEOF) { _bstr_t lpcstrlxx = (_bstr_t)pRst->GetCollect ("ProductName");//pRst->GetCollect强制为_bstr_t ((CListBox*)GetDlgItem(IDC_LIST1))->AddString(lpcstrlxx); //((CListBox*)GetDlgItem(IDC_LIST1))->AddString((_bstr_t)pRst->GetCollect ("ProductName")); _bstr_t strb = (_bstr_t)pRst->GetCollect ("ProductName"); CString strlxx = (LPCTSTR)strb; MessageBox(strlxx); pRst->MoveNext (); } CString stre1 = "e2"; CString strInsert1 = "insert into dbo.Products (ProductID,ProductName,Price) values ('727','"; strInsert1 += stre1; strInsert1 += "','2303')"; _bstr_t Insert1 = (_bstr_t)strInsert1;//ProductID是主键,不能重复,会奔溃! pConn->Execute(Insert1,NULL,adCmdText); MessageBox("yes!"); pRst->Close (); pConn->Close (); pRst.Release (); pConn.Release (); CoUninitialize();
相关文章推荐
- iOS之数据库小应用--从数据库取值,传值和跳转界面功能
- Android 数据库随apk一起打包 及带参数跳转到拨号界面
- Android 以webview的方式集成Dcloud 5+SDK 实现携带数据跳转原生界面
- Android 从app 携带参数 跳转到其他app的指定界面
- php传值,界面跳转,数据库连接,查询,读出,写入
- oc学习(一)定义变量和方法、界面跳转
- IIS-ASP(二) 使用数据库设计登陆界面
- Java模拟简易ATM机运行(无界面、无数据库)
- H5初学界面跳转
- mvc 表单提交跳转界面
- 从数据库中取 datetime类型,界面展示 yyyy-MM-dd
- iOS界面跳转动画
- GridView根据数据库返回的值,在显示到界面前对相关数据进行处理后显示
- 网站超时跳转到登录界面
- 非关系型数据库MongoDB安装及环境变量配置
- magento 如何在跳转到支付界面前自动发送邮件
- STATA 批量重命名,数据查重,行列转换,类型转换,变量截取和生成,数据库合并等命令
- TableViewCell 点击跳转多个不同的界面
- iOS 万能跳转界面方法 (runtime实用篇一)
- Android 手机卫士--导航界面3、4和功能列表界面跳转逻辑处理