⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flashallgoodsdate.cpp

📁 使用MFC界面连SQL2000实现管理操作
💻 CPP
字号:
// FlashAllGoodsDate.cpp : implementation file
//

#include "stdafx.h"
#include "数据库实践.h"
#include "FlashAllGoodsDate.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// FlashAllGoodsDate dialog


FlashAllGoodsDate::FlashAllGoodsDate(CWnd* pParent /*=NULL*/)
	: CDialog(FlashAllGoodsDate::IDD, pParent)
{
	//{{AFX_DATA_INIT(FlashAllGoodsDate)
	m_flashgoods = _T("");
	//}}AFX_DATA_INIT
}


void FlashAllGoodsDate::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(FlashAllGoodsDate)
	DDX_Text(pDX, IDC_EDIT1, m_flashgoods);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(FlashAllGoodsDate, CDialog)
	//{{AFX_MSG_MAP(FlashAllGoodsDate)
	ON_BN_CLICKED(IDC_BUTTON1, OnSubmit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// FlashAllGoodsDate message handlers

void FlashAllGoodsDate::OnSubmit() 
{
	// 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 del_all_goods '%s'",this->m_flashgoods);
	_variant_t   RecordsAffected; 
	AfxMessageBox(str);
	try
	{
 	    pConn->Execute((_bstr_t)str,NULL,adCmdText);
		AfxMessageBox("删除成功!");
	}
	catch(_com_error e)
	{
		AfxMessageBox(e.ErrorMessage());
	
	}



	pConn->Close();
	CDialog::OnOK();
}
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -