//把数据集中的修改保存到数据集中
dsUserInfo.AcceptChanges();
//////////
这并不是将修改保存到数据库

解决方案 »

  1.   

    dsUserInfo.AcceptChanges();
    --->>>
    daUserInfo.Update(dsUserInfo);
      

  2.   

    AcceptChanges并没有把数据更新到myAddressList.mdb
      

  3.   

    把dataset更新到数据库中:
    http://chs.gotdotnet.com/quickstart/howto/default.aspx
      

  4.   

    acewang(平平安安过一年) 都说了,俺就当给楼主顶一个!
      

  5.   

    我一直是对数据库直接UPDATA的呵呵
      

  6.   

    我又重新试过,加上 daUserInfo.Update(dsUserInfo);以后还是不能更新啊!怎么回事!
      

  7.   

    我更改后的代码如下,还是没法更新,恳请指教错处在何处?多谢!//修改旧密码
    OleDbConnection cnUserInfo;
    cnUserInfo = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\myAddressList.mdb;" + "Password=;User ID=Admin;Persist Security Info=false");cnUserInfo.Open();
    daUserInfo = new OleDbDataAdapter();
    daUserInfo.SelectCommand = new OleDbCommand("Select userName,password From T_UserInfo Where userName = '" + tbUserName.Text.Trim() + "'",cnUserInfo);
    //为数据适配器创建映射
    daUserInfo.TableMappings.AddRange(new DataTableMapping[]
    {
    new DataTableMapping("Table","T_UserInfo",new DataColumnMapping[] 
    {
    new DataColumnMapping("userName","userName"),
    new DataColumnMapping("password","password")
    })
    });
    dsUserInfo = new DataSet();
    daUserInfo.Fill(dsUserInfo,"T_UserInfo");
    DataRow dr;
    dr = dsUserInfo.Tables["T_UserInfo"].Rows[0];
    dr["password"] = tbNewPwdOk.Text.Trim();//把数据集中的修改保存到数据集中
    dsUserInfo.AcceptChanges();
    daUserInfo.Update(dsUserInfo);
    cnUserInfo.Close();
      

  8.   

    还有就是微软的 Access 数据库好像不支持 Update SQL 语句,用 Update
    语句的时候说是语法错误,我已经试过多次了,都是这样!
      

  9.   

    何必这么复杂啊?弄个UPDATE SQL语句什么都决绝了啊,
    你用个COMMAND,然后执行一个UPDATE语句,一切不就OVER了。而且代码很少;简单
      

  10.   

    dsUserInfo.AcceptChanges();
    daUserInfo.Update(dsUserInfo);
    -----------------------------------
    去掉dsUserInfo.AcceptChanges();
      

  11.   

    去掉dsUserInfo.AcceptChanges();就有错误了!其错误信息为如下:未处理的“System.InvalidOperationException”类型的异常出现在 system.data.dll 中。其他信息: 当传递具有已修改行的 DataRow 集合时,更新要求有效的 UpdateCommand。但是Access数据库又不支持Update语句,怎么办?多谢!
      

  12.   

    最好是用一个SqlDataAdapterSqlConnection myConnection = new SqlConnection(strSQL);
    SqlCommand myCommand       = new SqlCommand(strSql,myConnection);
    SqlDataAdapter myDA        = new SqlDataAdapter(myCommand);
    SqlCommandBuilder myCB     = new SqlCommandBuilder(myDA);
    myConnection.Open();
    myDA.Update(DS.Tables[0]);
    myConnection.Close();to acewang(平平安安过一年) :
    获取IIS各个站点绝对路径:
    DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
    foreach(DirectoryEntry _e in root.Children)
     {
         if(_e.SchemaClassName == "IIsWebServer")
         {
             string Text;
    Text = "IIS://localhost/W3SVC/"+_e.Name.ToString()+"/ROOT";
    DirectoryEntry rootfolder2 = new DirectoryEntry(Text);
    listBox1.Items.Add(rootfolder2.Properties["Path"][0].ToString());
    MessageBox.Show(rootfolder2.Properties["Path"][0].ToString());  
         }
      }
      

  13.   

    参考:
    --------------------------
    OleDbDataAdapter catDA = new OleDbDataAdapter("SELECT CategoryID, CategoryName FROM Categories", nwindConn);            catDA.UpdateCommand = new OleDbCommand("UPDATE Categories SET CategoryName = ? " +
                                           "WHERE CategoryID = ?" , nwindConn);catDA.UpdateCommand.Parameters.Add("@CategoryName", OleDbType.VarChar, 15, "CategoryName");OleDbParameter workParm = catDA.UpdateCommand.Parameters.Add("@CategoryID", OleDbType.Integer);
    workParm.SourceColumn = "CategoryID";
    workParm.SourceVersion = DataRowVersion.Original;DataSet catDS = new DataSet();
    catDA.Fill(catDS, "Categories");    DataRow cRow = catDS.Tables["Categories"].Rows[0];
    cRow["CategoryName"] = "New Category";
    catDA.Update(catDS);
      

  14.   

    see:
    Updating the Database with a DataAdapter and the DataSethttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset.asp
      

  15.   

    Update 语法对Access数据库好像不支持!总是提示如下所示的错误!“UPDATE 语句的语法错误!”如果在把下面的代码注释掉,则出现如下所示的错误!//为数据适配器创建映射
    /*
    daUserInfo.TableMappings.AddRange(new DataTableMapping[]
    {
    new DataTableMapping("Table","T_UserInfo",new DataColumnMapping[] 
    {
    new DataColumnMapping("userName","userName"),
    new DataColumnMapping("password","password")
    })
    });
    */这时的错误信息如下:
    “UPDATE 无法找到 TableMapping['Table'] 或 DataTable 'Table'”
      

  16.   

    加上
    SqlCommandBuilder cmdBuilder=new SqlCommandBuilde(catDS);
    catDS.UpdateCommand=cmdBuilder.GetUpdateCommand();
    catDA.Update(catDS,"表名");