Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please give me the solution

give me the exact souttion
Posted
Updated 15-Nov-12 22:06pm
v2
Comments
Nelek 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

1 solution

Hi
Hope this does what you want it to.

C#
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900