473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Importing text files

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
1 3252
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Awah Teh | last post by:
I am working on a project that involves importing IIS Log files into a SQL Server database (and these logfiles are big --> Some up to 2GB in size). Up until now I thought that DTS or the BULK...
11
by: Grim Reaper | last post by:
I am importing a .csv file into Access that has 37 fields. My problem is that sometimes the last field only has data at the end of the column (it looks like when you import a file into Access, for...
1
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am...
14
by: MLH | last post by:
GHudson has working procedures posted at http://www.access-programmers.co.uk/forums/showthread.php?t=66320 They work. Relationships, however, and some minor default settings are not preserved....
29
by: Natan | last post by:
When you create and aspx page, this is generated by default: using System; using System.Collections; using System.Collections.Specialized; using System.Configuration; using System.Text; using...
5
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All...
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
1
by: Kosmos | last post by:
Hey guys, I'm fairly familiar with access by now, but I've never worked with importing text into an access database. I have some fairly large text files (lets say, for example, a folder of 20 text...
1
by: gollumullog | last post by:
Good Day, I have been having this issue for quite a long time, and have yet to find an easy/elegant solution. I am trying to create tables in an Access database. I have these tables as CSV...
1
by: aconti74 | last post by:
Hello I am new to vba programming/coding. I am writing a program that goes through a directory of text files and imports them into the database. The problem is eventually the database gets to big...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.