| | |
Reading CSV file into a ADO recordset
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2006
Posts: 2
Reputation:
Solved Threads: 0
I'm relatively new to programming.
Problem:
I'm creating an ASP.NET app the needs to read a CSV file and filter the data.
I searched the net and only found classic ASP examples or all DB driven examples.
Does anyone have sample code. Or is there any other suggestions on how to read and filter. Thanks
Problem:
I'm creating an ASP.NET app the needs to read a CSV file and filter the data.
I searched the net and only found classic ASP examples or all DB driven examples.
Does anyone have sample code. Or is there any other suggestions on how to read and filter. Thanks
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
c# code
Hope it helps
ASP.NET Syntax (Toggle Plain Text)
using System.Data; //in some function System.Data.Odbc.OdbcConnection conn; DataTable dt; System.Data.Odbc.OdbcDataAdapter da; string connectionString; string importFolder; string fileName; importFolder = @"c:\importfile" //or pass it in -this is the folder in which the csv file is in fileName = "csvimport.csv" //or pass it in -this is the csv file to be imported connectionString= @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + importFolder + ";"; conn = new Odbc.OdbcConnection(connectionString) //we only pass it the folder. The csv file import is in the query which follows da = new System.data.Odbc.OdbcDataAdapter("select * from [" + strFileName + "]", conn); da.Fill(dt); //Your table is filled and uses the first row of the csv file as the column headings.
Hope it helps
•
•
Join Date: Jan 2006
Posts: 2
Reputation:
Solved Threads: 0
Thanks for the code f1_fan.
I'll try to work with the code.
Does anyone have a VB example as well.
I'll try to work with the code.
Does anyone have a VB example as well.
Is cable or satellite cheaper? - satellite tv dish provider
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
I will change it to vb but bear with me as my vb is rusty to say the least.
ASP.NET Syntax (Toggle Plain Text)
imports System.Data; //in some function Dim conn As System.Data.Odbc.OdbcConnection Dim dt As DataTable Dim da As System.Data.Odbc.OdbcDataAdapter; Dim connectionString As string Dim importFolder As string Dim fileName As string importFolder = "c:\importfile" //or pass it in -this is the folder in which the csv file is in fileName = "csvimport.csv" //or pass it in -this is the csv file to be imported connectionString= "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + importFolder + ";" conn = new Odbc.OdbcConnection(connectionString) //we only pass it the folder. The csv file import is in the query which follows da = new System.data.Odbc.OdbcDataAdapter("select * from [" + strFileName + "]", conn); da.Fill(dt); //Your table is filled and uses the first row of the csv file as the column headings.
•
•
Join Date: Feb 2006
Posts: 1
Reputation:
Solved Threads: 0
Can I access a remote csv? Example: http://www.domain.com/file.csv
![]() |
Similar Threads
- Reading in a *.csv file and loading the data into an Array (Java)
- How to read data from csv file in an array and parse (C++)
- CSV file (C)
- Need Help Reading a csv file created from MSExcel (C)
Other Threads in the ASP.NET Forum
- Previous Thread: ASP.NET Timer Button
- Next Thread: How to end a session immediately when the browser closes?
Views: 30613 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 activexcontrol advice ajax anathor asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdown dropdownmenu edit expose feedback flash flv folder form formatdecimal forms formview google grid gridview homeedition hosting identity iframe iis index javascript jquery list menu migration mono mssql multistepregistration nameisnotdeclared object objects order problem ratings refer rotatepage save search security serializesmo.table session silverlight smartcard sql sqlserver2005 suse textbox tracking typeof unauthorized update validation vb vb.net video view virtualdirectory vista visual-studio visualstudio web webarchitecture webdevelopemnt xml youareanotmemberofthedebuggerusers





