By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

Importing text files

P: n/a
Va
I am trying to import tab delimited text file into a
recordset. The code I am using is

conn_string = "Driver={Microsoft Text Driver (*.txt;
*.csv)};Dbq=c:\AMPS\Files\2538;DefaultDir=c:\temp; Extension
s=asc,csv,tab,txt;"

Set con = New ADODB.Connection
Set rst = New ADODB.Recordset

con.ConnectionString = strcs
con.Open
rst.Open "zzz.txt", strcs, adOpenStatic,
adLockReadOnly, adCmdTable
If any of the columns in the file is more than 256
characters, then open recordset fails. The message
is "Run-time error - [Microsoft][ODBC Text Driver] The
size of a field is too long". Is there any way of reading
fields with more than 256 characters?

Thanks

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Tue, 2 Sep 2003 22:51:05 -0700, "Va" <vi************@mail.com> wrote:

I am trying to import tab delimited text file into a
recordset. The code I am using is

conn_string = "Driver={Microsoft Text Driver (*.txt;
*.csv)};Dbq=c:\AMPS\Files\2538;DefaultDir=c:\temp; Extension
s=asc,csv,tab,txt;"

Set con = New ADODB.Connection
Set rst = New ADODB.Recordset

con.ConnectionString = strcs
con.Open


rst.Open "zzz.txt", strcs, adOpenStatic,
adLockReadOnly, adCmdTable


If any of the columns in the file is more than 256
characters, then open recordset fails. The message
is "Run-time error - [Microsoft][ODBC Text Driver] The
size of a field is too long". Is there any way of reading
fields with more than 256 characters?

Assuming you have a schema.ini file you will probably need to define this field as Memo or LongChar
(if using ODBC):

[TabDelimitedFile.txt]
ColNameHeader=False
Format=TabDelimited
CharacterSet=ANSI

Col1=Field1 Integer
Col2=Field2 Integer
Col3=Field3 Integer
Col4=Field4 Integer
Col5=Field5 Integer
Col6=Field6 Memo

http://msdn.microsoft.com/library/de...cjetsdk_98.asp
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.