Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Please give me the solution
 
give me the exact souttion
Posted 15-Nov-12 22:04pm
Edited 15-Nov-12 22:06pm
Nelek42.3K
v2
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

Hi
 
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;
 

con.Open();
da = new OleDb.OleDbDataAdapter(sql, con);
da.Fill(ds, dbTableName);
MaxRows = ds.Tables("FancyName").Rows.Count;
con.Close();
 
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.
 
Jacques
  Permalink  
Rate this: bad
good
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();
                    da.Fill(dt);
                    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";
         CSVExport.SaveToFile();
     }
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.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 Tadit Dash 330
2 Manas Bhardwaj 319
3 OriginalGriff 243
4 Sergey Alexandrovich Kryukov 205
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,716
2 Peter Leow 4,345
3 Maciej Los 3,540
4 Abhinav S 3,373


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid