using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
//定义一个数据绑定方法
private void BindData()
{
string query = "SELECT * FROM Authors"; //采用sql自带的Pubs数据库中的Authors表
SqlConnection myConnection = new SqlConnection("server=.;database=WebShoppe;user id=sa;password=;");
SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "Autho
用C#代码把SQL 数据库的表导出到Excel
最新推荐文章于 2023-11-08 15:56:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)