473,324 Members | 2,400 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,324 software developers and data experts.

How to read text-file using OLE DB provider

Hi!

I'm trying to read text file like...

"Field1";"Field2";"Field3";"Field4"
"ABCD";"EFGH";"1234";"20051020"
"AABB";"CCDD";"2468";"20051021"
"CCDD";"XXYY";"4321";"20051022"

....using OLE DB-provider. Unfortunately I can't affect in what kind of
form this file is saved :(

I don't know how to make ConnectionString for this kind of file?

I think it should be something like...

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myFileName &
";Extended Properties='Text;HDR=YES;...'"

....but how to specify in ConnectionString the fields are separated with
";" ?

--
Thanks in advance!

Mika
Nov 21 '05 #1
5 7594
Mika,

Have a look at this sample on our website.

http://www.vb-tips.com/default.aspx?...f-212f9e0de193

Be aware that you have to be in a culture that uses the ; as a csv seperator
(by instance probably complete continental Europe).

I hope this helps,

Cor
Nov 21 '05 #2
Cor Ligthert [MVP] wrote:
Mika,

Have a look at this sample on our website.

http://www.vb-tips.com/default.aspx?...f-212f9e0de193

Be aware that you have to be in a culture that uses the ; as a csv seperator
(by instance probably complete continental Europe).

I hope this helps,

Cor


I tried it, but got only first column with data retrieved - so how to
get all the columns retrieved?

I also checked of the "Regional and Language options" that there List
separator is really ;

I'm using english version WinXP Pro with finnish settings.

any more succestions?
Nov 21 '05 #3
Hi Mika,

Why don't you read the file with a text stream reader of the .NET Framework?
It would be faster and using an OLEDB Provider for that task seems to be a
bit overkill and it adds an extra dependency on the OLEDB components that
can be avoided...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Mika M" <ma***************@luukku.com> escribió en el mensaje
news:en**************@TK2MSFTNGP12.phx.gbl...
Hi!

I'm trying to read text file like...

"Field1";"Field2";"Field3";"Field4"
"ABCD";"EFGH";"1234";"20051020"
"AABB";"CCDD";"2468";"20051021"
"CCDD";"XXYY";"4321";"20051022"

...using OLE DB-provider. Unfortunately I can't affect in what kind of
form this file is saved :(

I don't know how to make ConnectionString for this kind of file?

I think it should be something like...

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myFileName & ";Extended
Properties='Text;HDR=YES;...'"

...but how to specify in ConnectionString the fields are separated with
";" ?

--
Thanks in advance!

Mika

Nov 21 '05 #4
Mika,

The CSV file that you use is a typical non English CSV file (based on comma
as decimal point).

I don't know where that setting is, maybe is it the decimal point setting in
your country settings.

Cor
Nov 21 '05 #5
Carlos J. Quintero [VB MVP] kirjoitti:
Hi Mika,

Why don't you read the file with a text stream reader of the .NET Framework?
It would be faster and using an OLEDB Provider for that task seems to be a
bit overkill and it adds an extra dependency on the OLEDB components that
can be avoided...


Because I already use OLE DB provider to import data from for example
Excel sheets in the same form. Then with only small changes would do it
for the text (CSV) files too.

I'm just trying to make it possible import data directly from CSV-file,
because quite often Excel is needed only to convert data from CSV-file
into desired form, so it would be good if this step could be avoided.

Looks like CSV-file reading using OLE DB provider does not care about
what is the setting in "Regional and Language options" List separator,
because I replaced in CSV-file ";" -> "," and then importing works fine
- but why like this way ??? :(
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mikko | last post by:
Is it possible to read "label" from form-field? <label for="product1">bread</label> <input id="product1" name="product1" type="text" size="3"> number comes with $_GET; but how do I read the...
2
by: Michael Winter | last post by:
Below is the IDL definition of the HTMLOptionElement. interface HTMLOptionElement : HTMLElement { readonly attribute HTMLFormElement form; attribute boolean defaultSelected;...
1
by: David | last post by:
In the event handler for ItemCommand, I am trying to read text of cells in the row programmatically, but can't get it working. //this is what I have in InitializeComponent...
2
by: Julie | last post by:
I'm wondering what standard/best practices are for the following scenario: I have a page representing several fields for stored data. If the user has sufficient access privileges, the page is...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
1
by: Tolgay Gül | last post by:
I need some codes that able to send and read data by serialport in VB.Net 2005 beta 2. I wrote some codes and It can send data via serialport but It cannot read what I send. I have looked up on...
15
by: mosipenko | last post by:
I used to have a problem with DBNull, but now my issue is: System.InvalidOperationException: Invalid attempt to read when no data is present Here's my code behind: Private Sub...
8
by: Zephyre | last post by:
I have some UTF-8 text files written in Chinese to be read. Now the only method that I know to read text from it is to use fopen() function. Thus, I must read the contents byte by byte, change the...
1
by: kannadhasan | last post by:
Input xml: .... <p> <b>Sample text:</b> <nbsp/>these are some sample text<i>text continues here</i> </p> ... out put I need when I read the <p> tag from an xsl document is: ...
9
by: Arepi | last post by:
Hi! I tryed this script to non blocked read in tk use Tk; use Term::ReadKey; ReadMode 4, STDIN; $in = \*STDIN;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.