#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();
}