Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ADO Error #3105

136 views
Skip to first unread message

Kurt W. Allen

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Hello All;

Does anyone know what IDISPATCH error #3105 means? I am using ADO to
connect to a JET database. I open a recordset and can walk through the
table just fine. All the rows are loaded properly. When I do an Update
after an AddNew(), I get the error #3105.

I am using the following code to upate the recordset with the new
data.

Any hints would be greatly appreciated. (One really good hint might be
where can I get error info, or trace info from ADO when these error
occur?)

Best,
Kurt A.
kwa...@Herakles.com

class CAdoLists
{
// data definitions for row variables.
_RecordsetPtr m_rs;
void WriteData();
void ReadData()
...
}

static char conn[] =
"Provider=Microsoft.Jet.OLEDB.3.51;"
"Data Source=c:\\Scr.mdb

CAdoLists list;
list.Open(conn);
list.m_rs->AddNew();
// Set data vars in list.
...
list.m_rs->Update(); <-- c_com_error exception thrown here.
IDispatchError #3105.

CAdoLists::CAdoLists()
{
m_OpenFlag = false;
HRESULT res = m_rs.CreateInstance("ADODB.Recordset.1.5");
assert(res == ERROR_SUCCESS);
}

void CADOCommon::Open(const char* connStr)
{
const char* sql = "Select Lists.* From Lists";
m_rs->Open((LPCTSTR) sql, connStr, adOpenDynamic,
adLockOptimistic, -1);
if (IsEOF() == true)
return;
MoveFirst();
}
void CAdoLists::WriteData()
{
FieldPtr fieldPtr;
_variant_t fieldData;

// Write field ListId
fieldPtr = m_rs->Fields->GetItem((short) 0);
fieldData.Clear();
fieldData.vt = VT_I4;
fieldData.lVal = m_ListId;
fieldPtr->PutValue(fieldData);

// Write field Name
fieldPtr = m_rs->Fields->GetItem((short) 1);
fieldData.Clear();
fieldData.bstrVal = _bstr_t((LPCTSTR) m_Name);
fieldPtr->PutValue(fieldData);

// Write field SubjectHdr
...
}


Jeremy Lloyd

unread,
Jan 3, 1999, 3:00:00 AM1/3/99
to
If your ListId column an auto-inc column? If it is you can't update it with
ADO. Or, I suspect you are not initialising your _vairant_t's properly.

You get extended error information from the Errors objects which belongs to
the connection object, though it doesn't usuallly help much.

Further, you are using a very long winded way of setting your field values.
_variant_t has heaps of data conversion operators.

For instance:


> fieldPtr = m_rs->Fields->GetItem((short) 1);
> fieldData.Clear();
> fieldData.bstrVal = _bstr_t((LPCTSTR) m_Name);
> fieldPtr->PutValue(fieldData);

Could be written as
fieldPtr = m_rs->Fields->Item[1];
fieldPtr->Value = m_Name;

But a better (IMHO) would be to assign a ptr to the fields collection to a
variable
FieldsPtr fldsPtr = m_rs->Fields;

then do this:
fldsPtr->Item[1]->Value = m_Name;
fldsPtr->Item[2]->Value = m_Field2;
fldsPtr->Item[3]->Value = m_Field3;

You can do the reverse for reading the data.

This will works for longs, bools, strings etc etc.

Finally, creating the ADO object in your constructor is not a great idea,
since doing so could thow an exception, and exceptions thrown in
constructors can cause memory leaks, due to the way the destructors are
called. Also when testing an HRESULT for success you should use "if
(SUCCEEDED(res))" since COM allows for multiple success return codes.

Hope this helps, either with your specific problem or generally.
Regards
Jeremy


Kurt W. Allen wrote in message <368e8d87...@news.visi.com>...

0 new messages