找不到类型或命名空间名称“SqlDataAdaper”(是否缺少 using 指令或程序集引用?)
using System;using System.Data;
using System.Configuration;
using System.Collections;
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 admin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindGrid();
}
private void BindGrid()
{
String str = "server='(local)';DataBase=kq;uid=sa;pwd=sa";
SqlConnection cn = new SqlConnection(str);
cn.Open();
String mysql = "select * from admin";
SqlDataAdaper da = new SqlDataAdaper(mysql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
cn.Close();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//获取要删除的记录的id并赋值给变量ID
string ID = this.GridView1.DataKeys[e.RowIndex][0].ToString();
logic.Class1 abc = new logic.Class1();
string Sql = "DELETE FROM" + configure.Class1.Dataname + " where id=" + ID + "";
abc.Exesql(Sql);
baindata();
}
//换页后触发
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//更新页值
this.GridView1.PageIndex = e.NewPageIndex;
baindata();//重新绑定记录
}
//点击编辑后触发
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView1.EditIndex = e.NewEditIndex;
baindata();
}
//当取消时触发
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.GridView1.EditIndex = -1;
baindata();
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("adminadd.aspx");
}
}