指定通过ODBC访问的默认日期值 [英] Specifying default date values for access via ODBC

查看:85
本文介绍了指定通过ODBC访问的默认日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它通过ODBC从Excel spreadsheeet读取作业候选数据,并通过ODBC在ACCESS表中填充它。我面临一些问题。

第一个问题是Excel中的出生日期字段。相当数量的候选人将他们的DOB列为N / A。 SQLGetData返回此字段的SQL_ERROR,但返回正确的(N / A)数据。这导致我使用了很多黑客。是否有设置使SQLGetData返回SQL_SUCCESS或SQL_SUCCESS_WITH_INFO为N / A。

第二个问题是Access中的出生日期字段。有没有办法为上面提到的字段指定一个NULL日期,其中Excel中的相应值是N / A?



我尝试了什么:



Visual Studio调试。在线帮助。

解决方案

如果您发布至少一些您在XLS中读取的代码并将其提交到数据库中,这将有所帮助。我相信您最好的选择是尝试将从XLS获得的值转换为Date类型值。如果该尝试失败,则在插入记录时使用NULL(确保该字段允许空值)。



HTH,

Mike

I have an application which reads job candidates data from an Excel spreadsheeet via ODBC and populates the same in an ACCESS table via ODBC. I am facing a couple of issues.
The first problem is with the date of birth field in Excel. A sizeable number of candidates have their DOB listed as "N/A". SQLGetData returns SQL_ERROR for this field but returns the correct ("N/A" ) data present. This is causing me to employ a lot of hacks. Is there a setting to make SQLGetData return SQL_SUCCESS or SQL_SUCCESS_WITH_INFO for "N/A".
The second problem is with the date of birth field in Access. Is there a way to specify a NULL date for the above mentioned field where the corresponding values in Excel are "N/A"?

What I have tried:

Visual Studio Debugging. Online help.

解决方案

It would help if you'd post at least some of the code you're using to read in the XLS and to submit it into the DB. I believe your best bet will be to attempt to convert the value that you get from the XLS to a Date type value. If that attempt fails then use NULL when inserting the record (make sure the field allows null values).

HTH,
Mike


这篇关于指定通过ODBC访问的默认日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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