public int Updata(DataSet ds) { DBAccess.DBHelper dbhelper = new DBAccess.DBHelper(); if (dbhelper.Update(ds) == 0) { return 0; } else { return 1; } }
public int Delete(MyWebControlLib.FieldValues FVS) { if (_tablename != "") { DBAccess.DBHelper h = new DBAccess.DBHelper(); SqlDataAdapter adapter = h.GetSqlDataAdapter(_tablename); string condition = " (1=1) "; for (int i = 0; i < FVS.Count; i++) { string values = ""; FVOperater o = FVS[i].FVOperater; switch (o) { case FVOperater.Great: values = " > '" + FVS[i].Value + "' "; break; case FVOperater.Less: values = " < '" + FVS[i].Value + "' "; break; case FVOperater.LikeB: values = " Like '%" + FVS[i].Value + "' "; break; case FVOperater.LikeBE: values = " Like '%" + FVS[i].Value + "%' "; break; case FVOperater.LikeE: values = " Like '" + FVS[i].Value + "%' "; break; case FVOperater.NotGreat: values = " <= '" + FVS[i].Value + "' "; break; case FVOperater.NotLess: values = " >= '" + FVS[i].Value + "' "; break; case FVOperater.In: values = " in (" + FVS[i].Value + ") "; break; case FVOperater.NotIn: values = " not in (" + FVS[i].Value + ") "; break; case FVOperater.NotEqual: values = " <> '" + FVS[i].Value + "' "; break; case FVOperater.Order: break; default: values = " = '" + FVS[i].Value + "' "; break; } condition = condition + _conditionOperater + FVS[i].FieldName + values; } adapter.SelectCommand.CommandText = "select * from " + _tablename + " where " + condition; DataSet ds = new DataSet(_tablename); adapter.Fill(ds, _tablename); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) ds.Tables[0].Rows[i].Delete(); //ʹ��������V2 DBAccess.DBHelper dh = new DBAccess.DBHelper(); dh.Update(ds); //��ʹ��������V1 //adapter.Update(ds,_tablename); return 0; } else return -3; }