Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > VB.Net: Importing CSV semi-colon delimited through OleDbConnection
 

VB.Net: Importing CSV semi-colon delimited through OleDbConnection

I have this code to show data that I import from a CSV-file that is semi-colon ( ; ) delimited.

Code Snippet

conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ System.Windows.Forms.Application.StartupPath & ";Extended Properties=""Text;HDR=Yes;FMT=Delimited""")


DataGridView1.DataSource = ds.Tables(0)
conn.Open()

cmd = New OleDbCommand("SELECT * FROM " + System.IO.Path.GetFileName(Application.StartupPath & _ "\RaetWhitePages.csv"), conn)

adapter = New OleDbDataAdapter(cmd)

adapter.SelectCommand = cmd

adapter.Fill(ds)


This has been working very well on the machine I have been developing this on, but now I move the application to my laptop it doesn't work anymore. I am 99.9% sure that the same application now uses a comma (,) as the field separator. I have done a lot of searches, but have not found a solution.

I have compared the regional settings from the develop machine with the laptop and made differences the laptop where needed. One thing I did change on the laptop was changing the list separator from comma to semi-colon, but to no avail.

Any suggestions where to look at? I prefer to have this solved where I declare 'conn' (in the oledbconnection call).

Thanks in advance!

Jan
Jan-Dirk  Thursday, November 06, 2008 8:45 AM

Hi Jan-Dirk

Welcome to MSDN. I have read your post and quite know your feeling. We have met similar case about migrating an application to another compute didn’t work properly when he used a SqlConncetion or OledbConncetion. So base on my experience, the problem of these cases were caused by the environment of the database. Different ODBC driver can cause different problem. So I want you can have a check if the two computer (develop machine and your laptop) have the same version of Microsoft Office. Also I need more information about your problem (e.g. where did you get the error message? What is that error message?). Thank you!

Sincerely,

Kira Qian

Kira Qian  Monday, November 10, 2008 3:40 AM
Hi Kira,

Thanks for your help!

The versions of office are identical on both computers. The PC's at the office are rolled-out all in exactly the same configuration.

I don't have the exact error message here, but will post it tomorrow. I don't have the computer here at the moment.

JD
Jan-Dirk  Monday, November 10, 2008 1:50 PM

Hi Jan-Dirk

I will now change the status of this thread into comment since you need time to pick up the error data from your computer. Please come back to give me the detail information once you have collected them. If you find the solution, please share the experience with all the member on the forum. Thank you!

Sincerely,

Kira Qian
Kira Qian  Wednesday, November 12, 2008 10:02 AM

You can use google to search for other answers

Custom Search

More Threads

• CaptionText in DataGridView
• Secrets of the BindingSource.Filter
• Add new row to bound DataGridView - almost works, but need help
• How to add an expression column
• DataGrid View Column problems.
• Paint problems on unbound DataGridView
• Creating Dynamic MenuItem in c# windows application
• How to format Datagridview columns to numeric.?? Column.Defaultcellstyle.format does not work
• Inserting multiple rows from datagrid to database
• DataGridView: remove the padding in RowHeaderCell?