•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 402,426 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,020 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 18960 | Replies: 4
![]() |
•
•
Join Date: Jan 2006
Posts: 2
Reputation:
Rep Power: 0
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
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation:
Rep Power: 3
Solved Threads: 10
c# code
Hope it helps
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:
Rep Power: 0
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
Location: Its the internet... i am everywhere lol
Posts: 274
Reputation:
Rep Power: 3
Solved Threads: 10
I will change it to vb but bear with me as my vb is rusty to say the least.
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:
Rep Power: 0
Solved Threads: 0
Can I access a remote csv? Example: http://www.domain.com/file.csv
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- 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)
- Reading in a *.csv file and loading the data into an Array (Java)
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?


Linear Mode