C#链接SQL数据库实现查询功能,怎么老是不显示数据,,代码如下
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSys...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = @"server=HUANGZHENG\SQL2012;
integrated security=true;
database=Lianxiren
";
SqlConnection conn = new SqlConnection(connStr);
string query = @"select *
from Label
";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataSet ds = new DataSet();
da.Fill(ds,"Label");
GridView1.DataSource = ds.Tables["Label"];
GridView1.DataBind();
}
} 展开
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = @"server=HUANGZHENG\SQL2012;
integrated security=true;
database=Lianxiren
";
SqlConnection conn = new SqlConnection(connStr);
string query = @"select *
from Label
";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataSet ds = new DataSet();
da.Fill(ds,"Label");
GridView1.DataSource = ds.Tables["Label"];
GridView1.DataBind();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询