473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Trying to read CSV file into VB.NET 2005

I have some code and I know the Connection string is wrong, but I don't know
the correct syntax. Can someone help please? I want to read a .CSV file
and input the data into a table. Am I on the right track? Any
help/corrctions would be appreciated. This is VS 2005, Windows Application
using VB.NET.
Dim sConnectionString As String = "Driver={Microsoft Text Driver" & _
"(*.txt; *.csv)};Dbq=C:\Stock
Market\;Extensions=asc,csv,tab,txt;"

Dim objConn As New Odbc.OdbcConnection(sConnectionString)
Dim objCmdSelect As New Odbc.OdbcCommand("SELECT * FROM
AMEX_20070302.csv", objConn)

Dim objAdapter1 As New
Odbc.OdbcDataAdapter(objCmdSelect.CommandText, objConn)
Dim objDataset1 As New DataSet()

objAdapter1.Fill(objDataset1, "Table1")
DataGridView1.DataSource = objDataset1.Tables(0).DefaultView
objConn.Close()

Mar 20 '07 #1
3 7146
This faq shows some code.

http://www.syncfusion.com/faq/window...earch/942.aspx

===============
Clay Burch
Syncfusion, Inc.

Mar 20 '07 #2
Thanks, that did the trick.
"ClayB" <cl***@syncfusion.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
This faq shows some code.

http://www.syncfusion.com/faq/window...earch/942.aspx

===============
Clay Burch
Syncfusion, Inc.

Mar 20 '07 #3
dude don't listen to these kids
use BULK INSERT in order to import CSV into a table
ADO.net is bloatware; sorry


On Mar 20, 9:43 am, "Zim Babwe" <zimba...@thecheckisinthemail.com>
wrote:
I have some code and I know the Connection string is wrong, but I don't know
the correct syntax. Can someone help please? I want to read a .CSV file
and input the data into a table. Am I on the right track? Any
help/corrctions would be appreciated. This is VS 2005, Windows Application
using VB.NET.

Dim sConnectionString As String = "Driver={Microsoft Text Driver" & _
"(*.txt; *.csv)};Dbq=C:\Stock
Market\;Extensions=asc,csv,tab,txt;"

Dim objConn As New Odbc.OdbcConnection(sConnectionString)
Dim objCmdSelect As New Odbc.OdbcCommand("SELECT * FROM
AMEX_20070302.csv", objConn)

Dim objAdapter1 As New
Odbc.OdbcDataAdapter(objCmdSelect.CommandText, objConn)
Dim objDataset1 As New DataSet()

objAdapter1.Fill(objDataset1, "Table1")
DataGridView1.DataSource = objDataset1.Tables(0).DefaultView
objConn.Close()

Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Fickbohm | last post by:
People, I am trying to determine the creation date of files in a folder. I am using the following code to find the folder and confirm that files exist in the folder. If someone could give me an...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
5
by: Mitchell S. Honnert | last post by:
Is there a way, given the full path of a folder on a network, that one can programatically tell if you have Read access to that folder? I have an application where the user is able to select a...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
2
by: rh.krish | last post by:
Hi I'm trying to open an excel file uploaded by the user and read the content. I'm able to save the file in the web server, but when I try to open it - I get the following error: "The Microsoft...
7
by: Tracks | last post by:
I have old legacy code from vb5 where data was written to a file with a variant declaration (this was actually a coding error?)... in vb5 the code was: Dim thisdata as integer Dim thatdata...
0
by: ttamilvanan81 | last post by:
Hai, I am doing a Struts application. In this application, i need to read a dbf file(foxpro database file) and it will be write to the SQL Server 2005. The application administrator will be...
5
by: Alan Silver | last post by:
Hello, Server configuration: Windows 2003 Server SP2 SQL Server 2000 SP4 ..NET v2.0.50727 just built up a new server using the same configuration as my current one. I even used the same CDs...
3
by: Robert Dunlop | last post by:
I am using Microsoft Visual Studio 2005 for development of an ASP.NET site, and I have a problem that greatly effects my workflow at times. It seems that after I upload new files anywhere within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.