?? lookup.cpp
字號:
// LookUp.cpp : implementation file
//
#include "stdafx.h"
#include "數據庫實踐.h"
#include "LookUp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// LookUp dialog
LookUp::LookUp(CWnd* pParent /*=NULL*/)
: CDialog(LookUp::IDD, pParent)
{
//{{AFX_DATA_INIT(LookUp)
m_lookup = _T("");
//}}AFX_DATA_INIT
}
void LookUp::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(LookUp)
DDX_Text(pDX, IDC_lookupText, m_lookup);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(LookUp, CDialog)
//{{AFX_MSG_MAP(LookUp)
ON_BN_CLICKED(IDC_BUTTON2, OnLookUpGoods)
ON_EN_CHANGE(IDC_lookupText, OnChangelookupText)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// LookUp message handlers
void LookUp::OnLookUpGoods()
{
// TODO: Add your control notification handler code here
_ConnectionPtr pConn;
_CommandPtr pCmd;
_RecordsetPtr pRst;
CoInitialize(NULL);
pConn.CreateInstance(__uuidof(Connection));//
pCmd.CreateInstance((__uuidof(Command)));
pRst.CreateInstance((__uuidof(Recordset)));
//connection string
pConn->ConnectionString="Provider=SQLOLEDB.1;Password=123456;Persist Security Info=TRUE;User ID=sa;Initial Catalog=超市管理系統";
//open connection
try
{
pConn->Open("","","",adConnectUnspecified);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
UpdateData(true);
CString str;
UpdateData(true);
str.Format("exec lookup_goods '%s'",this->m_lookup);
_variant_t RecordsAffected;
AfxMessageBox(str);
try
{
pConn->Execute((_bstr_t)str,NULL,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
AfxMessageBox("查詢成功!");
//pConn->Close();
CDialog::OnOK();
}
void LookUp::OnChangelookupText()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -