几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 酉空间:CAX软件开发(一)基础理论 » 专家系统 » Database
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2007-07-22, 03:32 PM   #1
yogy
高级会员
 
注册日期: 06-11
帖子: 1527
精华: 15
现金: 6353 标准币
资产: 6353 标准币
yogy 向着好的方向发展
默认 Adoaccessor.dsw工程

; ADOAccessor.def : Declares the module parameters.

LIBRARY "ADOAccessor.DLL"

EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
yogy离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
旧 2007-07-22, 03:38 PM   #2
yogy
高级会员
 
注册日期: 06-11
帖子: 1527
精华: 15
现金: 6353 标准币
资产: 6353 标准币
yogy 向着好的方向发展
默认 回复: Adoaccessor.dsw工程

2. stdafx.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#if !defined(AFX_STDAFX_H__667E9AB8_BDD9_4C7F_AEBD_9FADD0E3AE4C__INCLUDED_)
#define AFX_STDAFX_H__667E9AB8_BDD9_4C7F_AEBD_9FADD0E3AE4C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#import "E:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "adoEOF")
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__667E9AB8_BDD9_4C7F_AEBD_9FADD0E3AE4C__INCLUDED)

此帖于 2007-07-22 03:44 PM 被 yogy 编辑.
yogy离线中   回复时引用此帖
旧 2007-07-22, 03:50 PM   #3
yogy
高级会员
 
注册日期: 06-11
帖子: 1527
精华: 15
现金: 6353 标准币
资产: 6353 标准币
yogy 向着好的方向发展
默认 回复: Adoaccessor.dsw工程

3.ADOTier.h
// ADOTier.h : Declaration of the CADOTier
#ifndef __ADOTIER_H_
#define __ADOTIER_H_

#include "resource.h" // main symbols

/////////////////////////////////////////////////////////////////////////////
// CADOTier
class ATL_NO_VTABLE CADOTier :
public CComObjectRootEx<CComSingleThreadModel>,
public ISupportErrorInfo,
public CComCoClass<CADOTier, &CLSID_ADOTier>,
public IDispatchImpl<IADOTier, &IID_IADOTier, &LIBID_ADOACCESSORLib>
{
public:
CADOTier()
{
}

DECLARE_REGISTRY_RESOURCEID(IDR_ADOTIER)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CADOTier)
COM_INTERFACE_ENTRY(IADOTier)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IADOTier
public:
STDMETHOD(get_Empty)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(ADORelease)();
STDMETHOD(Requery)();
STDMETHOD(ChangeParameter)(/*[in]*/ long idx, /*[in]*/ enum DataTypeEnum type, /*[in]*/ VARIANT value, /*[in]*/ enum ParameterDirectionEnum where, /*[in]*/ long size);
STDMETHOD(put_StoredProc)(/*[in]*/ BSTR newVal);
STDMETHOD(CallStoredProc)(/*[in]*/ long idx1, /*[in]*/ BSTR idx2, /*[in]*/ BSTR idx3);
STDMETHOD(ParamQuery)(/*[in]*/ BSTR query, /*[in]*/ long idx1, /*[in]*/ BSTR idx2, /*[in]*/ BSTR idx3);
STDMETHOD(get_BOF)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(get_EOF)(/*[out, retval]*/ VARIANT_BOOL *pVal);
STDMETHOD(Prev)();
STDMETHOD(Last)();
STDMETHOD(Next)();
STDMETHOD(First)();
STDMETHOD(Close)();
STDMETHOD(get_FieldCount)(/*[out, retval]*/ long *pVal);
STDMETHODIMP put_FieldCount(/*[in]*/ long pVal);
STDMETHOD(get_Field)(/*[in]*/ VARIANT idx, /*[out, retval]*/ VARIANT *pVal);
STDMETHOD(put_Field)(/*[in]*/ VARIANT idx, /*[in]*/ VARIANT newVal);
STDMETHOD(Delete)();
STDMETHOD(Update)();
STDMETHOD(AppendParameter)(/*[in]*/ enum DataTypeEnum type, /*[in]*/ VARIANT value, /*[in]*/ enum ParameterDirectionEnum where, /*[in]*/ long size);
STDMETHOD(get_CommandText)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_CommandText)(/*[in]*/ BSTR newVal);
STDMETHOD(ExecuteCommand)(/*[in]*/ VARIANT_BOOL bStoredProcedure, /*[in]*/ VARIANT_BOOL bChangeRec);
STDMETHOD(ExecuteConnection)(/*[in]*/ BSTR query, /*[in]*/ VARIANT_BOOL bChangeRec);
STDMETHOD(CloseRecordset)(void);
STDMETHOD(OpenRecordset)(/*[in]*/ VARIANT query);
STDMETHOD(Open)(/*[in]*/ BSTR source, /*[in]*/ BSTR user, /*[in]*/ BSTR pwd);
private:
_CommandPtr m_command;
_RecordsetPtr m_recordset;
_ConnectionPtr m_connection;
};

#endif //__ADOTIER_H_

此帖于 2007-07-22 03:52 PM 被 yogy 编辑.
yogy离线中   回复时引用此帖
旧 2007-07-22, 03:51 PM   #4
yogy
高级会员
 
注册日期: 06-11
帖子: 1527
精华: 15
现金: 6353 标准币
资产: 6353 标准币
yogy 向着好的方向发展
默认 回复: Adoaccessor.dsw工程

4.ADOTier.h
// ADOTier.cpp : Implementation of CADOTier
#include "stdafx.h"
#include "ADOAccessor.h"
#include "ADOTier.h"
/////////////////////////////////////////////////////////////////////////////
// Need two distinct "empty" VARIANTs for Command::Execute
static VARIANT* pvtEmpty = static_cast<VARIANT*> (&vtMissing);
static _variant_t vtMissing2(DISP_E_PARAMNOTFOUND, VT_ERROR);
static VARIANT* pvtEmpty2 = static_cast<VARIANT*> (&vtMissing2);
STDMETHODIMP CADOTier::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IADOTier,
};
for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
{
if (InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}

STDMETHODIMP CADOTier::Open(BSTR source, BSTR user, BSTR pwd)
{
HRESULT hr = m_connection.CreateInstance(__uuidof(Connection));
if (SUCCEEDED(hr))
hr = m_connection->Open(source, user, pwd, adConnectUnspecified);
if (SUCCEEDED(hr))
hr = m_command.CreateInstance(__uuidof(Command));
if (SUCCEEDED(hr))
hr = m_recordset.CreateInstance(__uuidof(Recordset));
return hr;
}
STDMETHODIMP CADOTier::OpenRecordset(VARIANT query)
{
VARIANT v;
V_VT(&v) = VT_DISPATCH;
V_DISPATCH(&v) = (IDispatch*) m_connection;
// Need the AddRef() as VariantClear() calls Release(), unless fAddRef
// false indicates we're taking ownership
//
V_DISPATCH(&v)->AddRef();
return m_recordset->Open(query, v, adOpenDynamic, adLockOptimistic, adCmdText);
}
STDMETHODIMP CADOTier::CloseRecordset()
{
return m_recordset->Close();
}
STDMETHODIMP CADOTier::ExecuteConnection(BSTR query, VARIANT_BOOL bChangeRec)
{
_Recordset* prec = 0;
HRESULT hr = S_OK;
prec = m_connection->Execute(query, pvtEmpty, adCmdText);
if (prec)
{
if (bChangeRec)
m_recordset = prec;
else
prec->Release();
}
return hr;
}
STDMETHODIMP CADOTier::ExecuteCommand(VARIANT_BOOL bStoredProcedure, VARIANT_BOOL bChangeRec)
{
_Recordset* prec = 0;
HRESULT hr = S_OK;
if (bStoredProcedure)
prec = m_command->Execute(pvtEmpty, pvtEmpty2, adCmdStoredProc);
else
prec = m_command->Execute(pvtEmpty, pvtEmpty2, adCmdText);
if (prec)
{
if (bChangeRec)
m_recordset = prec;
else
prec->Release();
}
return hr;
}
STDMETHODIMP CADOTier::get_CommandText(BSTR *pVal)
{
return m_command->get_CommandText(pVal);
}
STDMETHODIMP CADOTier::put_CommandText(BSTR newVal)
{
return m_command->put_CommandText(newVal);
}
STDMETHODIMP CADOTier::AppendParameter(enum DataTypeEnum type, VARIANT value, enum ParameterDirectionEnum where, long size)
{
_ParameterPtr param;
HRESULT hr = param.CreateInstance(__uuidof(Parameter));
if (SUCCEEDED(hr))
hr = param->put_Type(type);
if (SUCCEEDED(hr))
hr = param->put_Value(value);
if (SUCCEEDED(hr))
hr = param->put_Direction(where);
if (SUCCEEDED(hr))
hr = param->put_Size(size);
Parameters* params = 0;
if (SUCCEEDED(hr))
hr = m_command->get_Parameters(&params);
if (SUCCEEDED(hr))
hr = params->Append(param);
if (SUCCEEDED(hr))
{
params->Release();
param->Release();
}
return hr;
}
STDMETHODIMP CADOTier::Update()
{
return m_recordset->Update();
}
STDMETHODIMP CADOTier::Delete()
{
return m_recordset->Delete(adAffectCurrent);
}
STDMETHODIMP CADOTier::get_Field(VARIANT idx, VARIANT *pVal)
{
Fields* fields = 0;
HRESULT hr = m_recordset->get_Fields(&fields);
Field* field = 0;
if (SUCCEEDED(hr))
hr = fields->get_Item(idx, &field);
if (SUCCEEDED(hr))
hr = field->get_Value(pVal);
if (SUCCEEDED(hr))
{
fields->Release();
field->Release();
}
return hr;
}
STDMETHODIMP CADOTier::put_Field(VARIANT idx, VARIANT newVal)
{
Fields* fields = 0;
HRESULT hr = m_recordset->get_Fields(&fields);
Field* field = 0;
if (SUCCEEDED(hr))
hr = fields->get_Item(idx, &field);
if (SUCCEEDED(hr))
hr = field->put_Value(newVal);
if (SUCCEEDED(hr))
{
fields->Release();
field->Release();
}
return hr;
}
STDMETHODIMP CADOTier::get_FieldCount(long *pVal)
{
Fields* fields = 0;
HRESULT hr = m_recordset->get_Fields(&fields);
if (SUCCEEDED(hr))
hr = fields->get_Count(pVal);
if (SUCCEEDED(hr))
fields->Release();
return hr;
}
STDMETHODIMP CADOTier::put_FieldCount(long pVal)
{
return S_OK;
}
STDMETHODIMP CADOTier::Close()
{
return m_connection->Close();
}
STDMETHODIMP CADOTier::First()
{
return m_recordset->MoveFirst();
}
STDMETHODIMP CADOTier::Next()
{
return m_recordset->MoveNext();
}
STDMETHODIMP CADOTier::Last()
{
return m_recordset->MoveLast();
}
STDMETHODIMP CADOTier::Prev()
{
return m_recordset->MovePrevious();
}
STDMETHODIMP CADOTier::get_EOF(VARIANT_BOOL *pVal)
{
return m_recordset->get_adoEOF(pVal);
}
STDMETHODIMP CADOTier::get_BOF(VARIANT_BOOL *pVal)
{
return m_recordset->get_BOF(pVal);
}
STDMETHODIMP CADOTier::ParamQuery(BSTR query, long idx1, BSTR idx2, BSTR idx3)
{
HRESULT hr = ChangeParameter(0, adInteger, (_variant_t) idx1, adParamInput, -1);
if (SUCCEEDED(hr))
hr = ChangeParameter(1, adVarChar, (_variant_t) idx2, adParamInput, 25);
if (SUCCEEDED(hr))
hr = ChangeParameter(2, adVarChar, (_variant_t) idx3, adParamInput, 80);
if (SUCCEEDED(hr))
hr = m_command->put_CommandText(query);
_Recordset* prec = 0;
if (SUCCEEDED(hr))
prec = m_command->Execute(pvtEmpty, pvtEmpty2, adCmdText);
if (prec) prec->Release();
return hr;
}
STDMETHODIMP CADOTier::CallStoredProc(long idx1, BSTR idx2, BSTR idx3)
{
HRESULT hr = ChangeParameter(0, adInteger, (_variant_t) idx1, adParamInput, 4);
if (SUCCEEDED(hr))
hr = ChangeParameter(1, adVarChar, (_variant_t) idx2, adParamInput, 25);
if (SUCCEEDED(hr))
hr = ChangeParameter(2, adVarChar, (_variant_t) idx3, adParamInput, 80);
if (SUCCEEDED(hr))
hr = m_command->put_CommandText(L"{call MyProc (?, ?, ?)}");
_Recordset* prec = 0;
if (SUCCEEDED(hr))
prec = m_command->Execute(pvtEmpty, pvtEmpty2, adCmdText);
if (prec) prec->Release();
return hr;
}
STDMETHODIMP CADOTier::put_StoredProc(BSTR newVal)
{
if (newVal == NULL)
newVal = ::SysAllocString(L"create procedure MyProc @i integer, @g varchar(25), @g varchar(80) into Guns (ID, Gun, [Gun Description]) values (@i, @g, @d) return");
HRESULT hr = m_command->put_CommandText(newVal);
_Recordset* prec = 0;
if (SUCCEEDED(hr))
prec = m_command->Execute(pvtEmpty, pvtEmpty2, adCmdText);
if (prec) prec->Release();
return hr;
}
STDMETHODIMP CADOTier::ChangeParameter(long idx, enum DataTypeEnum type, VARIANT value, enum ParameterDirectionEnum where, long size)
{
Parameters* params = 0;
HRESULT hr = m_command->get_Parameters(&params);
_Parameter* param = 0;
VARIANT v;
V_VT(&v) = VT_I4;
V_I4(&v) = idx;
if (SUCCEEDED(hr))
hr = params->get_Item(v, &param);
if (SUCCEEDED(hr))
hr = param->put_Type(type);
if (SUCCEEDED(hr))
hr = param->put_Value(value);
if (SUCCEEDED(hr))
hr = param->put_Direction(where);
if (SUCCEEDED(hr))
hr = param->put_Size(size);
if (SUCCEEDED(hr))
{
params->Release();
param->Release();
}
return hr;
}
STDMETHODIMP CADOTier::Requery()
{
return m_recordset->Requery(adCmdText);
}
STDMETHODIMP CADOTier::ADORelease()
{
m_command = 0;
m_recordset = 0;
m_connection = 0;
return S_OK;
}
STDMETHODIMP CADOTier::get_Empty(VARIANT_BOOL *pVal)
{
HRESULT hr = m_recordset->get_adoEOF(pVal);
if (SUCCEEDED(hr) && pVal)
hr = m_recordset->get_BOF(pVal);
return hr;
}
yogy离线中   回复时引用此帖
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 04:21 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多