473,749 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read text-file using OLE DB provider

Hi!

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

"Field1";"Field 2";"Field3";"Fi eld4"
"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 ConnectionStrin g for this kind of file?

I think it should be something like...

"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & myFileName &
";Extended Properties='Tex t;HDR=YES;...'"

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

--
Thanks in advance!

Mika
Nov 21 '05 #1
5 7636
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******** ******@TK2MSFTN GP12.phx.gbl...
Hi!

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

"Field1";"Field 2";"Field3";"Fi eld4"
"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 ConnectionStrin g for this kind of file?

I think it should be something like...

"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & myFileName & ";Extended
Properties='Tex t;HDR=YES;...'"

...but how to specify in ConnectionStrin g 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
9416
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 "bread"?
2
3418
by: Michael Winter | last post by:
Below is the IDL definition of the HTMLOptionElement. interface HTMLOptionElement : HTMLElement { readonly attribute HTMLFormElement form; attribute boolean defaultSelected; readonly attribute DOMString text; attribute long index; attribute boolean disabled; attribute DOMString label; readonly attribute boolean selected;
1
2790
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 this.dgList.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgList_Command); //this is the event handler. private void dgList_Command(object sender, DataGridCommandEventArgs e) {
2
1782
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 rendered w/ read/write text boxes and they can edit the various fields as needed. However, if the user doesn't have sufficient privileges (i.e. view only), the page is rendered w/ the text boxes set to read-only. However, this results in a rather...
16
453
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 in the Parent form and reference a child mdi form like this: Sub ReadText()
1
8579
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 internet and msdn and found some codes and samples but they are also can't read serial port. . It was so easy in VB 6.0 with mscomm object and oncommread events but now I don't understand how it reads data from serialport. You can see the codes...
15
2020
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 Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load Dim connectionString As String = "Data Source=server;Initial
8
27533
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 UTF-8 characters to Unicode, store the characters into wchar_t variables. But I think this method is too complex and isn't elegant at all. Are there any ways to read the UTF-8 text files as simple and convenient as the way that we read ANSI...
1
1394
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: <b>Sample text:</b>
9
1909
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
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.