Click here to Skip to main content
16,007,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCrash in Relese Build Pin
Ravi Jadhav1-Aug-02 20:50
Ravi Jadhav1-Aug-02 20:50 
GeneralRe: Crash in Relese Build Pin
Roman Nurik1-Aug-02 21:22
Roman Nurik1-Aug-02 21:22 
GeneralRe: Crash in Relese Build Pin
Ravi Jadhav1-Aug-02 21:52
Ravi Jadhav1-Aug-02 21:52 
GeneralRe: Crash in Relese Build Pin
[James Pullicino]1-Aug-02 23:40
[James Pullicino]1-Aug-02 23:40 
GeneralRe: Crash in Relese Build Pin
Ravi Jadhav2-Aug-02 0:54
Ravi Jadhav2-Aug-02 0:54 
GeneralRe: Crash in Relese Build Pin
[James Pullicino]2-Aug-02 3:08
[James Pullicino]2-Aug-02 3:08 
GeneralRe: Crash in Relese Build Pin
Anonymous2-Aug-02 6:13
Anonymous2-Aug-02 6:13 
GeneralHelp Needed - ADO RDS Pin
Praveena1-Aug-02 20:45
Praveena1-Aug-02 20:45 
Hi all,

I am accessing remote database by using ADO RDS. I am accessing Oracle database. I am getting an error message Object/Module not found. Pl can anyone help me where i am getting the problem. I am enclosing the source code of the prg. Its was the sample prg given in MSDN. I have modified according to my requirements i.e modified the server name,dsn,username.

Its there any other alternative to access remote database other than ADO RTS.


I am getting the exception in this statement.
/*****************
hr = _com_dispatch_method(pDF, dispids[0], DISPATCH_METHOD,VT_DISPATCH, (void*) &tempPtr, L"\x0008x0008\x0003",(BSTR) bstrConnect, (BSTR)bstrSQL, 0L);

**********************/

Pl. help me. Its very urgent.


#include <stdio.h>
#include <tchar.h>
#include <objbase.h>

#import "c:\program files\common files\system\ado\msado15.dll" rename("EOF", "adoEOF") rename("BOF", "adoBOF")
#import "c:\program files\common files\system\msadc\msadco.dll"
#import "c:\program files\common files\system\msadc\msadcf.dll"


#pragma warning(disable:4786; disable:4715)

const int MAX_FIELDS = 10; // Max # of Fields

HRESULT InitDataSpace(RDS::IDataspacePtr& pDS);
HRESULT InitDataFactory(RDS::IDataspacePtr pDS, _bstr_t Server, IDispatchPtr& pIDF);
HRESULT GetDISPID( DISPID& dspid, LPOLESTR FunctionName, IDispatch * obj);
HRESULT GetSRVset(ADODB::_RecordsetPtr& pRS, _bstr_t Server, _bstr_t ConnectStr, _bstr_t SQLStr);
HRESULT FlushChanges(IDispatchPtr& pIDF, DISPID funcID, _bstr_t ConnectStr, ADODB::_RecordsetPtr pRS);
void ReadRecordset(ADODB::_RecordsetPtr pRecordset);
void AddRecord(_variant_t FieldValues[], short iFieldCount, ADODB::_RecordsetPtr pRecordset);


extern "C" int WINAPI
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
HRESULT hResult = CoInitialize(NULL);

ADODB::_RecordsetPtr Authors;

_bstr_t bstrServer;
_bstr_t bstrConnect;
_bstr_t bstrSQL;

_variant_t Values[4]; // Holds data for AddRec

RDS::IDataspacePtr pDS;
IDispatchPtr pIDF; // Will hold Data Factory Object
DISPID SubmitChanges; // DISPID for the function

bstrServer = "http://god";
bstrConnect = " Provider=MSDAORA;dsn=newestudy;uid=estudy;pwd=estu
dy;";

bstrSQL = "Select INSPASSWD from insapplicants";

HRESULT hrResult;

// Get the DISPID for SubmitChanges
hrResult = InitDataSpace(pDS);
hrResult = InitDataFactory(pDS, bstrServer, pIDF);
LPOLESTR FName = {OLESTR("SubmitChanges")};
hrResult = GetDISPID( SubmitChanges, FName, pIDF);

// Get the Recordset
hrResult = GetSRVset( Authors, bstrServer, bstrConnect, bstrSQL);

// Read the Recordset
ReadRecordset(Authors);

pIDF.Release();
pDS.Release();
Authors->Close();
Authors.Release();

CoUninitialize();
return 0;
}

void dump_com_error(_com_error &e)
{
printf(_T("Exception!\n"));
printf(_T("\a\tCode = %08lx\n"), e.Error());
printf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
printf(_T("\a\tSource = %s\n"), (LPCTSTR) e.Source());
printf(_T("\a\tDescription = %s\n"), (LPCTSTR) e.Description());

}

HRESULT InitDataFactory(RDS::IDataspacePtr pDS, _bstr_t bstrServer, IDispatchPtr& pIDF)
{

HRESULT HR;
_variant_t Result;

try
{
Result = pDS->CreateObject(_bstr_t ("RDSSERVER.DataFactory"), bstrServer);
HR = Result.pdispVal->QueryInterface(_uuidof(IDispatch), (LPVOID *)&pIDF);
}
catch (_com_error &e)
{
MessageBox(NULL,e.ErrorMessage(),"",0);
printf(_T("Exception!\n"));
printf(_T("\a\tCode = %08lx\n"), e.Error());
printf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
printf(_T("\a\tSource = %s\n"), (LPCTSTR) e.Source());
printf(_T("\a\tDescription = %s\n"), (LPCTSTR) e.Description());
dump_com_error(e);
}

return HR;

}

HRESULT InitDataSpace(RDS::IDataspacePtr& pDS)
{
// This function inputs a pointer, and then initializes it
HRESULT hr;
hr = pDS.CreateInstance(_uuidof(RDS:ataSpace));
return hr;
}

HRESULT GetDISPID( DISPID& dispid, LPOLESTR FunctionName, IDispatch * obj)
{
HRESULT hr;
hr = obj->GetIDsOfNames(IID_NULL, &FunctionName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
return hr;

}

HRESULT FlushChanges(IDispatchPtr& pIDF, DISPID funcID, _bstr_t ConnectStr, ADODB::_RecordsetPtr pRS)
{
HRESULT hr;

try
{


hr = _com_dispatch_method(pIDF, funcID, DISPATCH_METHOD,
NULL, NULL, L"\x0008\x0009",
(BSTR) ConnectStr, (IDispatch *) pRS);

}
catch (_com_error &e)
{
dump_com_error(e);
}

return hr;
}

HRESULT GetSRVset(ADODB::_RecordsetPtr& pRS, _bstr_t bstrServer, _bstr_t bstrConnect, _bstr_t bstrSQL)
{

HRESULT hr;
RDS::IDataspacePtr pDS;
IDispatchPtr pDF; // Used for the DataFactory
IDispatch * tempPtr;
_variant_t Result;
try
{

hr = pDS.CreateInstance(_uuidof(RDS:ataSpace));
Result = pDS->CreateObject(_bstr_t ("RDSSERVER.DataFactory"), bstrServer);
hr = Result.pdispVal->QueryInterface(_uuidof(IDispatch), (LPVOID *) &pDF);

LPOLESTR Funky[1] = {OLESTR("Query")}; // name of the function to call
DISPID dispids[1]; // will hold the DISPID for the function
hr = pDF->GetIDsOfNames(IID_NULL, Funky, 1, LOCALE_SYSTEM_DEFAULT, dispids);



hr = _com_dispatch_method(pDF, dispids[0], DISPATCH_METHOD,
VT_DISPATCH, (void*) &tempPtr, L"\x0008\x0008\x0003",
(BSTR) bstrConnect, (BSTR)bstrSQL, 0L);

tempPtr->Release();

return hr;

}
catch (_com_error &e)
{ MessageBox(NULL,e.ErrorMessage(),"",0);
dump_com_error(e);
}
}

void AddRecord(_variant_t FieldValues[], short iFieldCount, ADODB::_RecordsetPtr pRecordset)
{
pRecordset->AddNew();
for (short i = 0; i < iFieldCount; i++)
{
pRecordset->Fields->Item[i]->Value = FieldValues[i];
}
}

void ReadRecordset(ADODB::_RecordsetPtr pRecordset)
{
pRecordset->MoveFirst();
while (!pRecordset->adoEOF)
{
for (short i = 0; i < pRecordset->Fields->Count; i++)
{
_bstr_t bstrName = pRecordset->Fields->Item[i]->Name;
_variant_t varValue = pRecordset->Fields->Item[i]->Value;
LPCTSTR lpszName = (LPCTSTR) bstrName;
_bstr_t bstrValue(varValue);
LPCTSTR lpszValue = (LPCTSTR) bstrValue;
if(i==0)
_tprintf(_T("\n"));
_tprintf(_T("%s: %s\n"), lpszName, lpszValue);
}

pRecordset->MoveNext();
}
}




Regards,
Praveena



Smile a while to keep your sorrow a mile
QuestionIs legal to use Windows icons? Pin
Joan M1-Aug-02 19:14
professionalJoan M1-Aug-02 19:14 
GeneralDetecting the Closest Point to a Region's Edge Pin
Swinefeaster1-Aug-02 16:59
Swinefeaster1-Aug-02 16:59 
GeneralRe: Detecting the Closest Point to a Region's Edge Pin
PJ Arends1-Aug-02 17:16
professionalPJ Arends1-Aug-02 17:16 
GeneralRe: Detecting the Closest Point to a Region's Edge Pin
Swinefeaster1-Aug-02 18:01
Swinefeaster1-Aug-02 18:01 
GeneralShow file property dialog box Pin
Jonatan Dahl1-Aug-02 16:58
Jonatan Dahl1-Aug-02 16:58 
GeneralRe: Show file property dialog box Pin
Ernest Laurentin1-Aug-02 18:49
Ernest Laurentin1-Aug-02 18:49 
GeneralRe: Show file property dialog box Pin
Jonatan Dahl2-Aug-02 1:12
Jonatan Dahl2-Aug-02 1:12 
GeneralAccessing Version information Pin
Stew1-Aug-02 15:48
Stew1-Aug-02 15:48 
GeneralRe: Accessing Version information Pin
Swinefeaster1-Aug-02 17:01
Swinefeaster1-Aug-02 17:01 
GeneralRe: Accessing Version information Pin
PJ Arends1-Aug-02 17:02
professionalPJ Arends1-Aug-02 17:02 
Generalusing CBitmapButton Pin
Mavrock1-Aug-02 13:16
Mavrock1-Aug-02 13:16 
GeneralRe: using CBitmapButton Pin
JohnnyG1-Aug-02 15:48
JohnnyG1-Aug-02 15:48 
GeneralRe: using CBitmapButton Pin
Joan M1-Aug-02 19:19
professionalJoan M1-Aug-02 19:19 
GeneralMessageBox Pin
Brad Jennings1-Aug-02 12:05
Brad Jennings1-Aug-02 12:05 
GeneralRe: MessageBox Pin
Tomasz Sowinski1-Aug-02 12:11
Tomasz Sowinski1-Aug-02 12:11 
GeneralRe: MessageBox Pin
Anonymous1-Aug-02 12:23
Anonymous1-Aug-02 12:23 
GeneralRe: MessageBox Pin
Tomasz Sowinski1-Aug-02 12:24
Tomasz Sowinski1-Aug-02 12:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.