- 积分
- 0
- 注册时间
- 2009-12-17
- 仿真币
-
- 最后登录
- 1970-1-1
|
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include <stdio.h>
#include <icrsint.h>
class CCustomRs : public CADORecordBinding
{
BEGIN_ADO_BINDING(CCustomRs)
ADO_NUMERIC_ENTRY(1,adInteger,a[0],1,0,m_ul_fnameStatus1,true)
ADO_NUMERIC_ENTRY(2,adInteger,a[1],1,0,m_ul_fnameStatus2,true)
ADO_NUMERIC_ENTRY(3,adInteger,a[2],1,0,m_ul_fnameStatus3,true)
ADO_NUMERIC_ENTRY(4,adInteger,a[3],1,0,m_ul_fnameStatus3,true)
END_ADO_BINDING()
public:
int a[4];
ULONG m_ul_fnameStatus1;
ULONG m_ul_fnameStatus2;
ULONG m_ul_fnameStatus3;
ULONG m_ul_fnameStatus4;
};
inline void TESTHR(HRESULT _hr)
{ if FAILED(_hr) _com_issue_error(_hr); }
extern"C"void datainsert(int a,int b,int c,int d)
{
_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));
::CoInitialize(NULL);
try
{
_RecordsetPtr pRs("ADODB.Recordset");
CCustomRs rs;
long ifstatus1=1;
long ifstatus2=2;
long ifstatus3=3;
long ifstatus4=4;
IADORecordBindingPtr picRs(pRs);
pRs->Open("SELECT * FROM 单元结点",
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=二维有压渗流数据.mdb",
adOpenStatic, adLockOptimistic, adCmdText);
TESTHR(picRs->BindToRecordset(&rs));
rs.a[0]=a;
rs.a[1]=b;
rs.a[2]=c;
rs.a[3]=d;
rs.m_ul_fnameStatus1=(ULONG)ifstatus1;
rs.m_ul_fnameStatus2=(ULONG)ifstatus2;
rs.m_ul_fnameStatus3=(ULONG)ifstatus3;
rs.m_ul_fnameStatus4=(ULONG)ifstatus4;
pRs->AddNew(&rs);
pRs->Update(&rs);
}
catch (_com_error &e)
{
printf("Error:\n");
printf("Code = %08lx\n", e.Error());
printf("Meaning = %s\n", e.ErrorMessage());
printf("Source = %s\n", (LPCSTR) e.Source());
printf("Description = %s\n", (LPCSTR) e.Description());
}
::CoUninitialize();
}
void main()
{int a,b,c,d;
a=5,b=2,c=3,d=4;
datainsert(a,b,c,d);
}
参数有问题?? |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|