Click here to Skip to main content
15,901,205 members
Home / Discussions / Database
   

Database

 
GeneralRe: Best way to import MSDE data into Access Pin
Anonymous2-Feb-05 7:00
Anonymous2-Feb-05 7:00 
GeneralRe: Best way to import MSDE data into Access Pin
RoedRunner14-Feb-05 10:48
RoedRunner14-Feb-05 10:48 
GeneralSELECT INTO Pin
Orville1-Feb-05 8:17
Orville1-Feb-05 8:17 
Generalupdate image column in MySQL Pin
kd83411-Feb-05 4:55
kd83411-Feb-05 4:55 
GeneralRestore SQl DB On Machine Problem... Pin
1-Feb-05 3:51
suss1-Feb-05 3:51 
GeneralRe: Restore SQl DB On Machine Problem... Pin
Rob Graham1-Feb-05 5:48
Rob Graham1-Feb-05 5:48 
GeneralRe: Restore SQl DB On Machine Problem... Pin
Just Greeky Creek2-Feb-05 22:04
Just Greeky Creek2-Feb-05 22:04 
GeneralHangs when attempting to close the Recordset object Pin
CodingFrenzy1-Feb-05 3:06
CodingFrenzy1-Feb-05 3:06 
I have a VC6 project that access' a visual fox pro database via the use of ADO. When I run the project in DEBUG mode everything works fine. When I run it in RELEASED mode on a development machine it also works fine. But when I try running it on a test machine it blows up.
There are multiple tables that I read in. I connect, create a Recordset, iterate through the DB (reading the field values as I go along), close the Recordset, close the connection, and then repeat the process for all other tables. Each table that gets imported has it's own method.
The results are weird as well. The first table will come in fine with no errors or exceptions.
Usually it will hang in the DisconnectADO() method that gets called at the end of the ImportSecondDB() method. But sometimes an exception is thrown that gets caught in the
catch(...). I'm not really sure what's going on here and have already lost close to a week's worth of development time on this. I have provided some code "snipets" bellow. Any help, comments, or suggestions will be most welcomed and greatly appreciated.



HRESULT ClassName::Run()
{
HRESULT hr = S_OK;

for (int i=0; i<2; ++i)
{
switch(i)
{
case 0:
hr = ImportFirstDB();
break;

case 1:
hr = ImportSecondDB();
break;

default:
ASSERT(FALSE);
hr = E_FAIL;
}
}
}



HRESULT ClassName::ImportFirstDB()
{
ado::_ConnectionPtr spConnection;
ado::_RecordsetPtr spRecSet;
CString ostr;
HRESULT hr = S_OK;
_variant_t ovField;

try
{
if (SUCCEEDED(hr = ConnectADO(spConnection, spRecSet)))
{
if (SUCCEEDED(hr = spRecSet->Open(L"SELECT * FROM daily", _variant_t((IDispatch*)spConnection, true), ado::adOpenStatic,ado::adLockReadOnly, ado::adOptionUnspecified)))
{
if (SUCCEEDED(hr = spRecSet->MoveFirst()))
{
while(SUCCEEDED(hr) && !spRecSet->GetadoEOF())
{
ovField = spRecSet->GetCollect("col name");
if (ovField.vt != VT_NULL)
{
ostr = (_bstr_t)ovField;
}
hr = spRecSet->MoveNext();
}
}
}
}
}
catch(_com_error& oE)
{
hr = ProcessError(&oE);
}
catch(...)
{
hr = ProcessConnectionError(spConnection);
}

DisconnectADO(spConnection, spRecSet);
return hr;
}



HRESULT ClassName::ImportSecondDB()
{
ado::_ConnectionPtr spConnection;
ado::_RecordsetPtr spRecSet;
CString ostr;
HRESULT hr = S_OK;
_variant_t ovField;

try
{
if (SUCCEEDED(hr = ConnectADO(spConnection, spRecSet)))
{
if (SUCCEEDED(hr = spRecSet->Open(L"SELECT * FROM daily", _variant_t((IDispatch*)spConnection, true), ado::adOpenStatic,ado::adLockReadOnly, ado::adOptionUnspecified)))
{
if (SUCCEEDED(hr = spRecSet->MoveFirst()))
{
while(SUCCEEDED(hr) && !spRecSet->GetadoEOF())
{
ovField = spRecSet->GetCollect("col name");
if (ovField.vt != VT_NULL)
{
ostr = (_bstr_t)ovField;
}
hr = spRecSet->MoveNext();
}
}
}
}
}
catch(_com_error& oE)
{
hr = ProcessError(&oE);
}
catch(...)
{
hr = ProcessConnectionError(spConnection);
}

DisconnectADO(spConnection, spRecSet);
return hr;
}



HRESULT ClassName::ConnectADO(ado::_ConnectionPtr& spConnection, ado::_RecordsetPtr& spRecSet)
{
CString ostrConnection;
HRESULT hr = S_OK;

try
{
if (SUCCEEDED(hr = spConnection.CreateInstance(__uuidof(ado::Connection))))
{
ostrConnection = _T("Provider=VFPOLEDB.1;");
ostrConnection += _T("Data Source=");
ostrConnection += ostrInputFile + _T(";");

if (SUCCEEDED(hr = spConnection->Open(_bstr_t(ostrConnection), L"", L"", ado::adModeUnknown)))
{
spRecSet.CreateInstance(__uuidof(ado::Recordset));
spRecSet->CursorLocation = ado::adUseClient;
}
else
{
_com_issue_error(hr);
}
}
catch(_com_error &oE)
{
hr = ProcessError(&oE, _T("AccountView_WINTask::ConnectADO() - InputFile: ") + ostrInputFile);
}
catch(...)
{
TRACE( "*** Unhandled Exception ***" );
hr = E_FAIL;
}

return hr;
}



HRESULT ClassName::DisconnectADO(ado::_ConnectionPtr& spConnection, ado::_RecordsetPtr& spRecSet)
{
ASSERT(spConnection);
ASSERT(spRecSet);
HRESULT hr = S_OK;

try
{
if (spRecSet)
{
if (spRecSet->State == ado::adStateOpen)
{
hr = spRecSet->Close();
}
}

if (spConnection)
{
if (spConnection->State == ado::adStateOpen)
{
hr = spConnection->Close();
}
}

spRecSet.Release();
spConnection.Release();
}
catch(_com_error& oE)
{
hr = ProcessError(&oE);
}
catch(...)
{
hr = ProcessConnectionError(spConnection);
}

return hr;
}
GeneralRe: Hangs when attempting to close the Recordset object Pin
Rob Graham1-Feb-05 5:56
Rob Graham1-Feb-05 5:56 
GeneralCalling functions in stored procedures Pin
Majid Shahabfar1-Feb-05 2:29
Majid Shahabfar1-Feb-05 2:29 
GeneralRe: Calling functions in stored procedures Pin
Colin Angus Mackay1-Feb-05 3:28
Colin Angus Mackay1-Feb-05 3:28 
GeneralRe: Calling functions in stored procedures Pin
Majid Shahabfar1-Feb-05 4:34
Majid Shahabfar1-Feb-05 4:34 
GeneralRe: Calling functions in stored procedures Pin
Colin Angus Mackay1-Feb-05 4:43
Colin Angus Mackay1-Feb-05 4:43 
GeneralDate stored as varchar required to be sorted Pin
xcavin31-Jan-05 19:49
xcavin31-Jan-05 19:49 
GeneralRe: Date stored as varchar required to be sorted Pin
Ritesh12341-Feb-05 2:04
Ritesh12341-Feb-05 2:04 
GeneralSQL Replication Conflicts Pin
Daminda31-Jan-05 19:09
Daminda31-Jan-05 19:09 
Generalretrieving datetime from recordset Pin
elephantstar31-Jan-05 8:49
elephantstar31-Jan-05 8:49 
GeneralRe: retrieving datetime from recordset Pin
WoutL31-Jan-05 10:59
WoutL31-Jan-05 10:59 
GeneralRe: retrieving datetime from recordset Pin
elephantstar31-Jan-05 11:14
elephantstar31-Jan-05 11:14 
GeneralTrigger Dates Pin
Tom Wright31-Jan-05 7:41
Tom Wright31-Jan-05 7:41 
GeneralRe: Trigger Dates Pin
Colin Angus Mackay31-Jan-05 9:38
Colin Angus Mackay31-Jan-05 9:38 
GeneralRe: Trigger Dates Pin
cmk31-Jan-05 9:53
cmk31-Jan-05 9:53 
GeneralRe: Trigger Dates Pin
Tom Wright31-Jan-05 11:53
Tom Wright31-Jan-05 11:53 
GeneralRe: Trigger Dates Pin
cmk31-Jan-05 14:23
cmk31-Jan-05 14:23 
GeneralRe: Trigger Dates Pin
Tom Wright1-Feb-05 11:11
Tom Wright1-Feb-05 11:11 

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.