Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I don't usually try to solicit help online (unless it's for some software technology that is not very well known, like, say, CUDA), but this problem has me tearing my hair out, as they say (I have too little hair to actually do that in the literal sense, but whatever)..

BTW, this is a C++ question. Apologies to the VB community if this is the wrong place to post this question..

The problem is with ADOX. More specifically, with the "Property" interface (or "class", or "object", or "IDispatch pointer", or whatever else you want to call it) defined by same.

I have no problem obtaining the "Property" interface's IDispatch pointer from the "Properties" collection, the latter of which I obtain from either the "Table", "Column", or "Index" interfaces. That part works great.

I also don't have any problems when using the "Property" Class's IDispatch pointer to get the "Name" and "Type" of an ADOX Property.

The problem is that whenever I try to get the "Value" of a "Property" (for which I have the "Name" and "Type"), it always returns an error.

The error code (aka: the "HRESULT") is always the same: 0x800a0cb3. Breaking this down, according to the (excellent) comments in WinError.h, I get:

Severity ("indicates success/fail"): Fail
Facility ("the facility code"): "FACILITY_CONTROL" (whatever that means)
Code ("the facility's status code"): 3251 (0xCB3)

According to the "ADO Error Reference", Error Code 3251 translates to an "ADO Error Code" (as opposed to an "ADOX Error Code", which doesn't seem to exist) called "adErrFeatureNotAvailable", which it describes as:

"The object or provider is not capable of performing the requested operation. Some operations depend on a particular provider version."

But that doesn't make a whole lot of sense. Why would any Database Provider provide the Property Name and Type, but not its value?

Speaking of Database Providers, I've tried to get the ADOX Property "Value" using several different database "Providers", among them are:

"Microsoft OLE DB Provider for SQL Server"
"SQL Server Native Client 10.0"
"SQL Server Native Client 11.0"

Oh, and yes, as is fairly obvious from the above, I'm connecting to a local instantiation of SQL Server Express 2008, and I'm accessing a database that I created myself, using SQL Server Authentication (i.e. using a name and password). I'm also connecting via the ADOX "DataLink" interface, which appears to work flawlessly (i.e. no errors, no surprises).

Scouring the internet for solutions (which I continue to do), I came across this page, the gist of which states (or rather, implies) that in order to "provide access to provider-specific properties", you first have to set the ADOX Table's "ParentCatalog" property to the "Catalog" (interface) that got you the Table object in the first place. Regardless of how stupid or redundant that sounds, I gave it a try anyway, and - wait for it - got another error.

This time the error code was 3219, which translates (according to the aforementioned web page) to an ADO Error Code called "adErrIntegrityViolation", which it (the web page) described as:

"Data value conflicts with the integrity constraints of the field. A new value for a Field would cause a duplicate key. A value that forms one side of a relationship between two records might not be updatable."

Which would be great if I was dealing with an ADO Field object - but I'm not.

All of which is very frustrating and confusing. Can anyone help?

What I have tried:

I've tried setting the ADOX::_Table's "ParentCatalog" property to the _Table's parent Catalog's IDispatch pointer, but got an error that didn't make sense in the context of a ADOX::_Table..
Posted
Updated 13-Aug-16 22:29pm
v3

1 solution

It looks like in your code logic is some design flaw. Check every step because on some assumption you are doing something wrong.

My best guess are accessing the db:
a) with read/write is wrong or
b) some version mismatch. (a newer db accessed with an older driver or statement)

Consider that error messages sometimes are hard to understand or misleading. It could be a bug.
 
Share this answer
 
Comments
Tacitonitus 15-Aug-16 5:43am    
What you've written is so far from what anyone would call a "solution", it's laughable. You've basically stated, "If you're code isn't working, you must be doing something wrong." Wow, pure genius. Wish I'd thought of that. Next time you have nothing whatsoever to offer other than meritless insults, please keep it to yourself. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900