在一个简单的datagridview中,它在运行时给出了错误(编译错误):(源错误:
第11行:
第12行:
第13行:)
mycode的
public partial class website : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Fillgrid();
}
public void Fillgrid()
{
Dataset ds = new Dataset();
SqlConnection cn = new SqlConnection(@"Server=.\SQLEXPRESS; DataBase=first; Integrated Security=true;");
cn.Open();
SqlCommand cmd;
cmd = new SqlCommand("select * from attendance", cn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);
cn.Close();
selectGridView.DataSource = ds;
selectGridView.DataBind();
}
}
答案 0 :(得分:0)
我认为您可以使用以下代码!!
Dataset ds = new Dataset();
SqlConnection cn = new SqlConnection(@"Server=.\SQLEXPRESS; DataBase=first; Integrated Security=true;");
cn.Open();
SqlDataAdapter adapter = new SqlDataAdapter("select * from attendance", cn);
adapter.Fill(ds,"attendance");
cn.Close();
selectGridView.DataSource = ds;
selectGridView.DataBind();