【C#】C# SQL数据操作

        dataModel sqlinfo = new dataModel();
        private SqlConnection conn;
        private SqlDataAdapter rs;
        private DataSet myDataSet;
        private BindingManagerBase myBind;
        private string sql=null;
        conn = sqlinfo.ReturnConn();
        if (conn != null)
        {
             conn = sqlinfo.ReturnConn();
        }
        else
        {
             conn.Close();
        }
        string sql = "select M_bh,M_zh from [manageinfo]";
        myDataSet = new DataSet();
        rs = new SqlDataAdapter(sql, conn);
        rs.Fill(myDataSet, "manageinfo");
        myBind = this.BindingContext[myDataSet, "manageinfo"];

//Add
  DataRow dr=MyDataSet.Tables["UserList"].NewRow();   
  dr["UserName"]   =   "周讯";   
  dr["ReMark"]   =   "100";   
  dr["Comment"]   =   "漂亮MM";   
  MyDataSet.Tables.Rows.Add(dr);   
    
//Edit
  MyDataSet.Tables["UserList"].Rows[0]["UserName"]="飞刀大哥"; 

//Dele
  MyDataSet.Tables["UserList"],Rows[0].Delete();

//back
  if(MyDataSet.HasErrors)   
  {   
      MyDataSet.RejectChanges();   
  }

//Update
  MyComm.Update(MyDataSet,"UserList");    


已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页