004
26.01.2005, 10:19 Uhr
andy_mann
|
Hallo,
Habe jetz aber weiter gesuch und folgenden source gefunden:
C++: |
#include "stdafx.h"
// BeginProcedureParametersCpp // ADO COM Komponente einbinden (-> steckt in der DLL msado15.dll) #import "C:\Programme\Gemeinsame Dateien\System\ado\msado15.dll" rename("EOF","ADOEOF") // #import "msado15.dll" #import "C:\Programme\Gemeinsame Dateien\System\ado\msadox.dll" no_namespace
// #include "iostream.h" #include "stdio.h" #include "conio.h"
using namespace std;
//Function declarations inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);}; void ProcedureParametersX(void);
////////////////////////////////////////////////////////// // // // Main Function // // // ////////////////////////////////////////////////////////// void main() { if(FAILED(::CoInitialize(NULL))) return;
ProcedureParametersX();
::CoUninitialize(); }
////////////////////////////////////////////////////////// // // // ProcedureParametersX Function // // // ////////////////////////////////////////////////////////// void ProcedureParametersX() { HRESULT hr = S_OK;
// Define ADOX object pointers. // Initialize pointers on define. // These are in the ADOX:: namespace. _CatalogPtr m_pCatalog = NULL;
//Define ADODB object pointers. ADODB::_ConnectionPtr m_pCnn = NULL; ADODB::_CommandPtr m_pCommand = NULL; ADODB::_ParameterPtr m_pParameter = NULL;
try { TESTHR(hr = m_pCnn.CreateInstance(__uuidof(ADODB::Connection)));
//Open the Connection m_pCnn->Open("Provider='Microsoft.JET.OLEDB.4.0';" "Data Source='c:\\Nordwind.mdb';","","",NULL);
TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(Catalog)));
//Open the catalog m_pCatalog->PutActiveConnection(_variant_t((IDispatch *)m_pCnn));
//Get the command object m_pCommand = m_pCatalog->Procedures->GetItem("Benutzer")->GetCommand();
_variant_t vIndex;
//Retrieve Parameter information m_pCommand->Parameters->Refresh(); for (long lIndex = 0; lIndex < m_pCommand->Parameters->Count; lIndex ++) { vIndex = lIndex; m_pParameter = m_pCommand->Parameters->GetItem(vIndex); cout << m_pParameter->Name << ":" << m_pParameter->Type << "\n" << endl; } } catch(_com_error &e) { // Notify the user of errors if any. _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); printf("\n\tSource : %s \n\tdescription : %s \n ", (LPCSTR)bstrSource,(LPCSTR)bstrDescription); }
catch(...) { cout << "Error occured in ProcedureParametersX...."<< endl; } } // EndProcedureParametersCpp
|
Er Kompeliert es und macht die verbindung zur Datenbank.
Aber bei:
C++: |
m_pCommand = m_pCatalog->Procedures->GetItem("Benutzer")->GetCommand();
|
bricht er ab und sagt das er das Objekt nicht finden kann. Die Tabelle existiert aber.
Hat dazu jemand eine idee ??
Gruß und Danke andy_mann |