#define INITGUID
#import “c:/Program Files/Common Files/System/ADO/msado15.dll” /
no_namespace rename(“EOF”, “EndOfFile”)
#include <stdio.h>
#include <icrsint.h>
#include <time.h>
#include <tchar.h>
VOID main()
{
HRESULT hr;
IADORecordBinding *picRs = NULL;
::CoInitialize(NULL);
_ConnectionPtr pConn;
hr = pConn.CreateInstance(__uuidof(Connection));
pConn->Open((LPCTSTR)”DSN”, (LPCTSTR)”USER”, (LPCTSTR)”PASSWORD”, adConnectUnspecified);
_CommandPtr pCommand = NULL;
_ParameterPtr pParameter = NULL;
DWORD dwVehiID = 1234;
DWORD dwPlanVehiID = 1111;
DWORD dwDeparID = 1111;
if (pConn == NULL) { return; }
try
{
if (FAILED(hr = pCommand.CreateInstance(__uuidof(Command))))
_com_issue_error(hr);
pCommand->ActiveConnection = pConn;
pCommand->CommandText = “sp_apts_insdeparture”;
pCommand->CommandType = adCmdStoredProc;
pParameter.CreateInstance(__uuidof(Parameter));
pParameter = pCommand->CreateParameter((“bFirstChanged”), adInteger, adParamInput, sizeof(int), (_variant_t)(long)(1));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“nLineID”), adInteger, adParamInput, sizeof(int), (_variant_t)(long)(3));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“nVehiID”), adUnsignedInt, adParamInput, sizeof(dwVehiID), (_variant_t)(long)(dwVehiID));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“tBeginTime”), adVarChar, adParamInput, _tcslen(“2009-01-09 15:15:15”), _variant_t(“2009-01-09 15:15:15”));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“tEndTime”), adVarChar, adParamInput, _tcslen(“2009-01-09 16:15:15”), _variant_t(“2009-01-09 16:15:15”));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“eDirection”), adTinyInt, adParamInput, sizeof(BYTE), _variant_t((BYTE)1));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“nFlag”), adTinyInt, adParamInput, sizeof(BYTE), _variant_t((BYTE)1));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“planed_driver_id”), adInteger, adParamInput, sizeof(int), (_variant_t)(long)(8888));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“actual_driver_id”), adInteger, adParamInput, sizeof(int), (_variant_t)(long)(8888));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“planed_vehi_id”), adUnsignedInt, adParamInput, sizeof(dwPlanVehiID), (_variant_t)(long)(dwPlanVehiID));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“szcomment”), adVarChar, adParamInput, _tcslen(” “), _variant_t(” “));
pCommand->Parameters->Append(pParameter);
pParameter = pCommand->CreateParameter((“id”), adUnsignedInt, adParamOutput, sizeof(dwDeparID), (_variant_t)(long)(dwDeparID));
pCommand->Parameters->Append(pParameter);
pCommand->Execute(NULL, NULL, adCmdStoredProc);
_variant_t varRet=pCommand->Parameters->GetItem(_bstr_t(“id”))->GetValue();
}
catch (_com_error& ) { return; }
CoUninitialize();
}
今天的文章ADO CreateParameter 测试程序 (绑定参数类型和数据库中不一样是否能正确执行)分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/12678.html