Upload .csv file to Codebehind and Convert it to Dataset using C#

HI friends

this example is going to teach you how to upload a .csv file using file upload control and how to Convert the content of .csv file into Dataset so that this Dataset can be used further in Programe


need to place button in page and write Code in Upload_Click() as



        DataTable dtCVSData = null;
        using (OleDbDataAdapter oleDA = new OleDbDataAdapter())
            using (OleDbConnection oleCon = new OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + filePath + “;Extended Properties=\”Text;HDR=Yes;FMT=Delimited;\””))
                using (OleDbCommand oleCmd = new OleDbCommand(“SELECT * FROM [” + fileName + “]”, oleCon))
                    oleDA.SelectCommand = oleCmd;
                    dtCVSData = new DataTable();


Finally the content of csv file is on dtCVSData Dataset

you can store it in session or you can utilize the same

thats it



About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s