Solved

Vb.net ODBC query from .csv file

Posted on 2011-09-27
6
720 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now