ADOX :: _ property:get_value()*总是*失败! ! [英] ADOX::_property:get_value() *always* fails ! !

查看:92
本文介绍了ADOX :: _ property:get_value()*总是*失败! !的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常不会尝试在线寻求帮助(除非是某些软件技术并不是很有名,比如CUDA),但这个问题让我撕裂了我的头发,就像他们说的那样(我有从字面意义上来说实际上做的太少,但无论如何......



BTW,这是一个C ++问题。如果这是发布此问题的错误位置,请向VB社区道歉..



问题在于ADOX。更具体地说,使用属性接口(或类,或对象,或IDispatch指针,或其他任何你想要调用它的方式)由相同的定义。



从Properties集合中获取Property接口的IDispatch指针没有问题,后者是从Table,Column或Index接口获得的。那部分效果很好。



使用Property类的IDispatch指针获取Name和Type时,我也没有任何问题ADOX财产。



问题在于每当我试图获得财产的价值时(我有名称和类型) ),总是返回错误。



错误代码(又名:HRESULT)始终相同:0x800a0cb3。打破这一点,根据WinError.h中的(优秀)评论,我得到:



严重程度(表示成功/失败):失败

设施(设施代码):FACILITY_CONTROL(无论这意味着什么)

代码(设施的状态代码):3251(0xCB3)



根据 ADO错误参考,错误代码3251转换为ADO错误代码(与ADOX错误代码相对,似乎不存在)称为adErrFeatureNotAvailable,它描述为:



对象或提供者无法执行请求的操作。某些操作取决于特定的提供者版本。



但这并没有多大意义。为什么任何数据库提供程序都提供属性名称和类型,而不是它的值?



说到数据库提供程序,我试图获得ADOX属性Value使用几个不同的数据库提供者,其中包括:



用于SQL Server的Microsoft OLE DB提供程序

SQL Server Native Client 10.0

SQL Server Native Client 11.0



哦,是的,从上面可以明显看出,我正在连接到SQL Server Express 2008的本地实例,我正在使用SQL Server身份验证(即使用名称和密码)访问我自己创建的数据库。我也通过ADOXDataLink接口进行连接,它看起来完美无缺(即没有错误,没有惊喜)。



在互联网上寻找解决方案(其中我继续这样做,我遇到了这个页面,其中的要点(或者更确切地说,暗示)为了提供对特定于提供者的属性的访问,您首先必须将ADOX表的ParentCatalog属性设置为到达的目录(接口)首先是Table对象。无论听起来多么愚蠢或多余,我还是试了一下,然后 - 等待它 - 又出现了另一个错误。



这次错误代码是3219,它(根据前面提到的网页)翻译成一个名为adErrIntegrityViolation的ADO错误代码,它(网页)描述为:



数据值冲突具有字段的完整性约束。字段的新值将导致重复键。形成两个记录之间关系的一侧的值可能不可更新。



如果我处理的是ADO Field对象,那会很棒 - 但我不是。



所有这些都令人非常沮丧和困惑。有人可以帮忙吗?



我的尝试:



我'尝试将ADOX :: _ Table的ParentCatalog属性设置为_Table的父目录的IDispatch指针,但是在ADOX :: _ Table的上下文中出现了一个没有意义的错误..

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..

推荐答案

在您的代码逻辑中看起来是一些设计缺陷。检查每一步,因为在某种假设下你做错了什么。



我最好的猜测是访问数据库:

a)读/写错误或

b)一些版本不匹配。 (使用较旧的驱动程序或语句访问的较新的数据库)



考虑错误消息有时难以理解或误导。这可能是一个错误。
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.


这篇关于ADOX :: _ property:get_value()*总是*失败! !的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆