中国程序员联盟 正在重新改版中ing 不便之处还请见谅 改版后将内容涉及java delphi .net php
 
  首页 | 数据库开发 | 网络通讯 | 多线程 | 多媒体开发 | 图像处理 | 程序人生 | 系统函数 | 控件开发 | Web服务
 
  当前位置:笨鱼delphi技术网>数据库开发>开发应用>文章内容

delphi 文本导入数据库

来源:国外 关于:Luka 发布时间:2007-07-04   [收藏] [推荐]
I found the answer to my problem, adding IMEX=1 to the connection string
tells the query to interprete all the data as text. And then I convert
string to number with strtofloat();

The connection string then looks like this:

adoquery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=g:\temp+';Extended Properties=''text;FMT=Delimited; IMEX=1''';

To answer Del, all the files have numbers with comma;
To answer Chris, schema.ini file is needed if the text file is TAB
delimited, and when delimiter is comma, or some other symbol (like ;) it is
not needed.
===
Thanks for the IMEX information - I am glad you have solved the problem.
IFAICT this does not seem to be documented by MS with respect to text
import (however,
http://support.microsoft.com/kb/194124/EN-US/ describes
IMEX for import from Excel).
note : Setting IMEX=1 tells the driver to use Import mode. In this state, the registry setting ImportMixedTypes=Text will be noticed. This forces mixed data to be converted to text. For this to work reliably, you may also have to modify the registry setting, TypeGuessRows=8. The ISAM driver by default looks at the first eight rows and from that sampling determines the datatype. If this eight row sampling is all numeric, then setting IMEX=1 will not convert the default datatype to Text; it will remain numeric.

You must be careful that IMEX=1 not be used indiscriminately. This is IMPORT mode, so the results may be unpredictable if you try to do appends or updates of data in this mode.

[浏览: 次]   
上一篇:delphi eof 或Bof为真,或可能记录已被删除   下一篇:delphi 如何给日期时间字段赋空值
[收藏] [推荐] [返回顶部] [打印本页] [关闭窗口]  
    评论加载中…
google adsense热点文章
·delphi Delphi_三谈多态——善用virtua
·delphi 条形码处理
·delphi Delphi_三层开发基本概念介绍
·delphi 汉字转拼音码(上)
·delphi CS构架下的客户端自动更新程序
·delphi Olevariant
·delphi 在Dephi中使用TStream读写数据
·delphi delphi处理流
·delphi 汉字转拼音码(下)
·delphi 关于使用COM对象的方法
·delphi MTS组件——从理论到实践
·delphi 汉字转拼音码(中3)
     delphi技术网 | firefox 下载 | Avant Browser下载 | dedecms 技术网 | drupal 爱好者 | php 技术网
  Copyright@www.delphichm.com,2006-2009.All Rights Reserved.
 
程序员联盟 | delphi Java .net|QQ:707102932