ImageDBDoc.cpp
资源名称:ImageDB.rar [点击查看]
上传用户:bst807
上传日期:2022-07-10
资源大小:74k
文件大小:3k
源码类别:
数据库编程
开发平台:
Visual C++
- // ImageDBDoc.cpp : implementation of the CImageDBDoc class
- //
- #include "stdafx.h"
- #include "ImageDB.h"
- #include "ImageDBDoc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CImageDBDoc
- IMPLEMENT_DYNCREATE(CImageDBDoc, CDocument)
- BEGIN_MESSAGE_MAP(CImageDBDoc, CDocument)
- //{{AFX_MSG_MAP(CImageDBDoc)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CImageDBDoc construction/destruction
- CImageDBDoc::CImageDBDoc()
- {
- // TODO: add one-time construction code here
- }
- CImageDBDoc::~CImageDBDoc()
- {
- }
- BOOL CImageDBDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- // TODO: add reinitialization code here
- m_pConnection.CreateInstance(__uuidof(Connection));
- m_pConnection->ConnectionString="File Name=image.udl";
- m_pConnection->ConnectionTimeout=20;
- m_pConnection->Open("","Admin","",adConnectUnspecified);
- /*m_pConnection->Execute("insert player values('04','vc++',0x)",NULL,adCmdText);
- _variant_t varSQL;
- varSQL="select photo from player where pno='04'";
- m_pRecordset.CreateInstance(__uuidof(Recordset));
- m_pRecordset->Open(varSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
- _StreamPtr pStm;
- pStm.CreateInstance("ADODB.Stream");
- _variant_t varOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
- long lDataSize = m_pRecordset->GetFields()->GetItem("photo")->ActualSize;
- pStm->PutType(adTypeBinary);
- pStm->Open( varOptional,adModeUnknown,adOpenStreamUnspecified, _bstr_t(), _bstr_t());
- pStm->LoadFromFile("e:\folder.jpg");//读入文件
- _variant_t varBLOB=pStm->Read(adReadAll);
- m_pRecordset->GetFields()->GetItem("photo")->Value = varBLOB;
- m_pRecordset->Update();
- m_pRecordset->Close();*/
- // (SDI documents will reuse this document)
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CImageDBDoc serialization
- void CImageDBDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CImageDBDoc diagnostics
- #ifdef _DEBUG
- void CImageDBDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CImageDBDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CImageDBDoc commands