April 23rd, 2013, 03:09 AM
[C++ ADO- SQL] pFields->GetItem (index)->GetValue () - throws an exception when field
I'm using ADO to link my WinAPI app with MS Access (SQL statements).
All works perfectly - without any problems i can read and write to the db (although i find ADO itself a bit annoying and painful :-) )
Anyways, there is one problem i cannot really deal with by myself anymore, when i read the fields from pField and when the particular field is empty (blank) then following throws the exception:
Obviously i can somehow handle this using try / catch (_com_error & ) but i rather not do that coz i use try/catch to catch "real" errors.
Forcing the user to always fill all fields in is also nothing i want to do coz with a massive amount of data he/she needs to enter, doing this for non mandatory fields would be very painful and simply pointless. So when i read the db and some fields are empty i just wanna get the pointer to the empty string ('\0'):
_bstr_t jakisstring = _bstr_t(pFields->GetItem(nIndex)->GetValue());
but as i mentioned the app immediately throws the error
I know there's been a threat for this already:
but it does not seem it's been addressed, so here i am posting this once again myself.
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!