I have a simple button for exporting a database table from MySQL to excel file. So far its destination is hardcoded to C:/ drive. When you press the Export button you get excel file automatically exported to C: without the user able to see it. Here is the code:
//button for Exporting to Excel (.xls)
//hardcoded destination to C:/
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string connectionString = "server=localhost; UserId=root; database=dbcss; ";
MySqlConnection con = new MySqlConnection(connectionString);
con.Open();
string getProject = ddlProjectID.SelectedValue; //get the already selected project from the dropdown menu
//create sql command object
string cmdText = "SELECT activity_id , activity_name , wbs_no , activity_status , wbs_name , sequence , pad , project_id , start_date , finish_date INTO OUTFILE C://TASK.xls FROM management WHERE project_id = " + getProject + " ;";
MySqlCommand cmd = new MySqlCommand(cmdText, con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
我怎么能做一个窗户,让你们能够浏览你们的c子和选择目的地?
Any help will be appreciated Thanks ;)