?? altergoods.cpp
字號:
// AlterGoods.cpp : implementation file
//
#include "stdafx.h"
#include "數(shù)據(jù)庫實踐.h"
#include "AlterGoods.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// AlterGoods dialog
AlterGoods::AlterGoods(CWnd* pParent /*=NULL*/)
: CDialog(AlterGoods::IDD, pParent)
{
//{{AFX_DATA_INIT(AlterGoods)
m_goodid = 0;
m_goodsname = _T("");
m_goodsprice = _T("");
m_goodsnum = 0;
//}}AFX_DATA_INIT
}
void AlterGoods::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(AlterGoods)
DDX_Control(pDX, IDC_BUTTON1, m_Submit);
DDX_Text(pDX, IDC_EDIT1, m_goodid);
DDX_Text(pDX, IDC_EDIT2, m_goodsname);
DDX_Text(pDX, IDC_EDIT3, m_goodsprice);
DDX_Text(pDX, IDC_EDIT4, m_goodsnum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(AlterGoods, CDialog)
//{{AFX_MSG_MAP(AlterGoods)
ON_BN_CLICKED(IDC_BUTTON1, OnSumbit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// AlterGoods message handlers
void AlterGoods::OnSumbit()
{
// 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=超市管理系統(tǒng)";
//open connection
try
{
pConn->Open("","","",adConnectUnspecified);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
UpdateData(true);
CString str;
UpdateData(true);
str.Format("exec alter_goods %d,'%s','%s',%d",this->m_goodid,this->m_goodsname,this->m_goodsprice,this->m_goodsnum);
_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();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -