Solved

Vb.net ODBC query from .csv file

Posted on 2011-09-27
6
782 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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