Solved

Vb.net ODBC query from .csv file

Posted on 2011-09-27
6
737 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

773 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