用编程可以实现GridView的填充
{
string ConnectionString = "Data Source=JOHN-PC\\SQLEXPRESS;Initial Catalog=asp;Integrated Security=True";
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
// cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from 账户";
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{ GridView1.DataSource = dr;
GridView1.DataBind();
}
}
}
经比较在连接字符串处比SqlDataSource配置数据库时多了\\SQLEXPRESS不知道是不是这儿的问题,该怎么解决,才能使用GridView的配置数据源的功能,请各位赐教!!!
{
string ConnectionString = "Data Source=JOHN-PC\\SQLEXPRESS;Initial Catalog=asp;Integrated Security=True";
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
// cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from 账户";
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{ GridView1.DataSource = dr;
GridView1.DataBind();
}
}
}
经比较在连接字符串处比SqlDataSource配置数据库时多了\\SQLEXPRESS不知道是不是这儿的问题,该怎么解决,才能使用GridView的配置数据源的功能,请各位赐教!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货