你把SDK装好,里面就有很多例子:)

解决方案 »

  1.   

    look into:
    Walkthrough: Editing an Access Database with ADO.NET
    http://www.microsoft.com/indonesia/msdn/adon_wtaccessdb.asp
      

  2.   

    http://expert.csdn.net/Expert/topic/2681/2681662.xml?temp=.2815058
      

  3.   

    download the sample:
    http://download.microsoft.com/download/c/b/9/cb93399c-2ecd-4d31-bde6-82bd74f4c79b/ADONETAccessDB.exe
      

  4.   

    //创建类的时候调用
    private void CreateDataAccess(){
    this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
    this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
    this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
    this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
    // 
    // sqlConnection1
    // 
    this.sqlConnection1.ConnectionString = "workstation id=SX;packet size=4096;user id=sa;data source=dbserver;persist security" +
    " info=False;initial catalog=dbname";
    // 
    // sqlDataAdapter1
    // 
    this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
    this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
    this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
    this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
    new System.Data.Common.DataTableMapping("Table", "ECOM_FeeDetail", new System.Data.Common.DataColumnMapping[] {
    new System.Data.Common.DataColumnMapping("ID", "ID"),
    new System.Data.Common.DataColumnMapping("OBR_PKID", "OBR_PKID"),
    new System.Data.Common.DataColumnMapping("FeeType_PKID", "FeeType_PKID"),
    new System.Data.Common.DataColumnMapping("FeeNumber", "FeeNumber")})});
    this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
    // 
    // sqlSelectCommand1
    // 
    this.sqlSelectCommand1.CommandText = "SELECT ID, OBR_PKID, FeeType_PKID, FeeNumber FROM FeeDetail";
    this.sqlSelectCommand1.Connection = this.sqlConnection1;
    // 
    // sqlInsertCommand1
    // 
    this.sqlInsertCommand1.CommandText = "INSERT INTO FeeDetail(OBR_PKID, FeeType_PKID, FeeNumber) VALUES (@OBR_PKID, " +
    "@FeeType_PKID, @FeeNumber); SELECT ID, OBR_PKID, FeeType_PKID, FeeNumber FROM " +
    "FeeDetail WHERE (ID = @@IDENTITY)";
    this.sqlInsertCommand1.Connection = this.sqlConnection1;
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@OBR_PKID", System.Data.SqlDbType.Int, 4, "OBR_PKID"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FeeType_PKID", System.Data.SqlDbType.Int, 4, "FeeType_PKID"));
    this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FeeNumber", System.Data.SqlDbType.Money, 8, "FeeNumber"));
    // 
    // sqlUpdateCommand1
    // 
    this.sqlUpdateCommand1.CommandText = @"UPDATE FeeDetail SET OBR_PKID = @OBR_PKID, FeeType_PKID = @FeeType_PKID, FeeNumber = @FeeNumber WHERE (ID = @Original_ID) AND (FeeNumber = @Original_FeeNumber OR @Original_FeeNumber IS NULL AND FeeNumber IS NULL) AND (FeeType_PKID = @Original_FeeType_PKID) AND (OBR_PKID = @Original_OBR_PKID); SELECT ID, OBR_PKID, FeeType_PKID, FeeNumber FROM FeeDetail WHERE (ID = @ID)";
    this.sqlUpdateCommand1.Connection = this.sqlConnection1;
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@OBR_PKID", System.Data.SqlDbType.Int, 4, "OBR_PKID"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FeeType_PKID", System.Data.SqlDbType.Int, 4, "FeeType_PKID"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@FeeNumber", System.Data.SqlDbType.Money, 8, "FeeNumber"));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FeeNumber", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "FeeNumber", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FeeType_PKID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "FeeType_PKID", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_OBR_PKID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OBR_PKID", System.Data.DataRowVersion.Original, null));
    this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4, "ID"));
    // 
    // sqlDeleteCommand1
    // 
    this.sqlDeleteCommand1.CommandText = "DELETE FROM FeeDetail WHERE (ID = @Original_ID) AND (FeeNumber = @Original_F" +
    "eeNumber OR @Original_FeeNumber IS NULL AND FeeNumber IS NULL) AND (FeeType_PKID" +
    " = @Original_FeeType_PKID) AND (OBR_PKID = @Original_OBR_PKID)";
    this.sqlDeleteCommand1.Connection = this.sqlConnection1;
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FeeNumber", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "FeeNumber", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_FeeType_PKID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "FeeType_PKID", System.Data.DataRowVersion.Original, null));
    this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_OBR_PKID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "OBR_PKID", System.Data.DataRowVersion.Original, null));
    }//将数据与DataGrid绑定
    public void BindData()
    {
      this.dataSet1 = new DataSet();
      this.sqlDataAdapter1.Fill(dataSet1);
      this.dataGrid1.SetDataBinding(dataSet1);
    }//向数据库提交数据
    public void Post()
    {
      this.sqlDataAdapter1.Update(this.dataSet1);
    }
      

  5.   

    在UpdateCommand_Click事件中用
    TextBox[] arrText=new TextBox[1];
    arrText[0]=(TextBox)e.Item.Cells[1].Controls[0];//编辑状态下的第一个文本框
    string UptTxt = arrText[0].Text.Trim(); //取得第一个文本框中的值
    下面就可以调用方法来修改数据
      

  6.   

    http://chs.gotdotnet.com/quickstart/aspplus/doc/webdatalist.aspx
    datalist控件
      

  7.   

    http://chs.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/doc_datagrid.aspx#paging
    里面很详细,你看看