My Blog!   

Tip of my blog


阅读(1560) 评论(0)

Why Do I Get "Native error code message" When I Call A LabWindows/CVI SQL Toolkit Function In My Program?

Primary Software: LabWindows/CVI Add-ons>>Enterprise Connectivity Toolset
Primary Software Version: 1.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

When calling some LabWindows/CVI SQL Toolkit functions, I get a Native error code message. What is the source of this error?

A Native error code is an error that is returned by the underlying database provider (i.e. the database driver you are using to communicate with your database file) or by the underlying Windows ADO (ActiveX Data Objects) layer.

This type of error does not indicate that there is something inherently wrong with the SQL toolkit or CVI itself, but rather indicates that you are trying to perform an operation with your particular database that is not supported. Most often, it is caused by an improper SQL statement, such as trying to pass an improper datatype to the database, or by trying to execute a specific function of the database incorrectly.

National Instruments does not provide database provider-specific technical support for trying to troubleshoot what a particular database does and does not support when interacting with it through the SQL Toolkit. You can seek this type of support through the 3rd party database providers themselves. What the SQL Toolkit does provide you with though is a set of useful error detection and interpretation functions that might lead to a possible explanation for what is going on with your underlying database provider. In order to determine if you are getting a particular type of error from a function call, look at the following information quoted directly from the LabWindows/CVI SQL Toolkit Help under Error Checking:

"The SQL Library functions return one of three types of values: result codes, handles, and data. You can compare a result code with DB_SUCCESS to determine if an error occurred. Handles refer to such items as database connections or activated SQL statements. If a function returns a handle, a value less than or equal to zero indicates an error. You can then call DBError to determine the error number. You also can call DBErrorMessage to get the text of the error message. For functions that return data, such as DBColumnName, you should call DBError to determine whether an error occurred.

hdbc = DBConnect (hdbc);
if (hdbc <= 0) {
errorCode = DBError();
errorMsg = DBErrorMsg();
printf("Error number %d\n%s\n", errorCode, errorMsg);

Now, if you do determine that the error is a Native error, usually indicated by the return value of a call to DBError being equal to DB_ODBC_ERROR, DB_DBSYS_ERROR or DB_AUTOMATION_ERROR, you can then call the DBNativeError function to retrieve the Native error code that your database provider or ADO reported. You should then consult your database provider manual, the 3rd party developer, or the Microsoft ADO/ODBC technical support pages described below for more information as to what might have caused it to happen.

Related Links:
External Link: Microsoft Universal Data Access
KnowledgeBase 1YKI602L: Which SQL Functions Can I Use with the LabWindows/CVI SQL Toolkit 2.0?
KnowledgeBase 1LQ7KVUT: Programmatically Specifying an Arbitrary File as the Data Source with the CVI-SQL Toolkit
KnowledgeBase 2QDEBL6I: Why Do I Get Error -2147352573 When I Run SQL Toolkit 2.0 Examples for LabWindows/CVI Version 6.0?
Product Manuals: LabWindows/CVI SQL Toolkit Help


by 进化中的兔子 发表于:2010/2/25 12:43:22
My subject | 我的主题

New entries | 新发表

Messages Board | 留言板

Guest Comments | 新评注

Blogger Login | 登陆栏
Blog Infomation | 信息栏
博客名称:嵌入式系统&虚拟仪器 日志总数:450 评论数量:277 访问次数:1781245 建立时间::2005年10月25日
Blog Infomation | 搜索栏
Blog Infomation | 收藏栏



中华工控网 | 联系我们 | 工控论坛首页 | 工控博客首页 | 博客注册 | 博客登陆


中华工控网 © Copyright 2013. All rights reserved.