我有一个简单的按钮,用于将数据库表从MySQL导出到excel文件。到目前为止,它的目标是硬编码到C:/驱动器。当您按下导出按钮时,您将获得excel文件自动导出到C:用户无法看到它。 这是代码:
//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());
}
}
如何在弹出窗口的地方弹出电脑并选择目的地?
任何帮助将不胜感激 谢谢;)
答案 0 :(得分:1)