Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
Please give me the solution
give me the exact souttion
Posted 15-Nov-12 23:04pm
Edited 15-Nov-12 23:06pm
Nelek at 16-Nov-12 4:08am
Do you realize you are demanding in a place where people help because they want to do it and where the main objective is to learn.
Such a post won't give you many results
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hope this does what you want it to.
OleDb.OleDbConnection con = new OleDb.OleDbConnection();
string dbProvider = null;
string dbSource = null;
string dbTableName = null;
string sql1 = null;
int MaxRows = 0;
string outputCSV = "";
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ";
//Define these three variables
dbSource = "C:/Marks.mdb";
dbTableName = "Science_Marks";
int noOfColumns = 1;

con.ConnectionString = dbProvider + dbSource;
DataSet ds = new DataSet();
OleDb.OleDbDataAdapter da;
sql1 = "SELECT * FROM " + dbTableName;

da = new OleDb.OleDbDataAdapter(sql, con);
da.Fill(ds, dbTableName);
MaxRows = ds.Tables("FancyName").Rows.Count;
for (int i = 0; i < MaxRows; i++) {
	for (int j = 0; j < noOfColumns; j++) {
		outputCSV = outputCSV + ds.Tables("FancyName").Rows(i).Item(j)+",";
	outputCSV = outputCSV + "\r\n";
//Save outputCSV to file, either by Save File Dialog or StreamWriter.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Look at below code:
private void btnLoad_Click(object sender, EventArgs e)
            using (OleDbConnection oleDbConnection = new OleDbConnection())
                oleDbConnection.ConnectionString = this.textBox1.Text;
                OleDbCommand oleDbCommand = new OleDbCommand();
                oleDbCommand.CommandText = this.textBox2.Text;
                oleDbCommand.Connection = oleDbConnection;
                using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
                    DataTable dt = new DataTable();
                    dataGridView1.DataSource = dt;
private void btnRUN_Click(object sender, EventArgs e)
         TXTExport CSVExport = new TXTExport();
         CSVExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
         CSVExport.DataTable = this.dataGridView1.DataSource as DataTable;
         CSVExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
         CSVExport.FileName = "CSV0721.csv";
Below code requires a : data export tool[^] If you have few data, you can use a free dataexport library, it is a community edition of above tool.actually, this tool also can export data from MDb SQL or other database, command, list view to word,excel,pdf,html,xml,text,ms access,rtf etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100