Solved

Vb.net ODBC query from .csv file

Posted on 2011-09-27
6
748 Views
Last Modified: 2012-05-12
Hi,

I am using the following connection string to build a datatable in vb.net:

        Dim conn As New OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & "\\lettsisa02\DHL Reports\ROSSTEST" & ";Extensions=asc,csv,tab,txt")

My issue is that the column headings contain the first row of data in the .csv file. Is their a setting to turn this off?

Regards,

Ross
0
Comment
Question by:ross13
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:DerZauberer
ID: 36708525
You can specify additional options in the connect string to control handling of first row as header.

& ";Extended Properties=""text;HDR=No;FMT=Delimited"""
0
 

Author Comment

by:ross13
ID: 36708943
Hi,

I tried the following but still no joy:

        Dim conn As New Odbc.OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & "\\lettsisa02\DHL Reports\ROSSTEST" & ";Extended Properties=""text;HDR=No;FMT=Delimited")

Regards,

Ross
0
 
LVL 5

Expert Comment

by:DerZauberer
ID: 36709346
I think i made a mistake, with the Text Driver you can specify ";HDR=No" directly, no need for extended proeprties ... please try like this:

Dim conn As New Odbc.OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & "\\lettsisa02\DHL Reports\ROSSTEST" & ";HDR=NO")
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:ross13
ID: 36908934
Hi,

I tried it but no luck.

Cheers,

Ross
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36912305
0
 
LVL 5

Accepted Solution

by:
DerZauberer earned 500 total points
ID: 36924788
Ok, here's another option you have.
You can create a file named "schema.ini" inside your data folder that describes how to handle the data files.

If you have a table file named "table1.txt" f.e. that has semicolon separated values, three columns and you don't want first row to be interpreted as header then your "schema.ini" can look like this:

[table1.txt]
ColNameHeader=False
Format=Delimited(;)
MaxScanRows=0
CharacterSet=OEM
Col1=F1 Char Width 255
Col2=F2 Char Width 255
Col3=F3 Char Width 255

Open in new window


You can use the "ODBC Datasources" in "administrative tools" with the Microsoft Text-Driver and a file dsn to manage the "format definition".
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question