私有 int DBUpdate() {
DAL dal = new DAL();
string upd = "UPDATE [RPform] SET [ProjectName] = '@pname', [ProjectCode] = '@pcode', [Country] = @cnt, ";
upd += "[StartDate] = '@startdate', [FinishDate] = '@finishdate', [TotalParticipants] = @totpart, [ArrivalDate] = '@arrivedate', ";
upd += "[AirportTransfer] = @airtran, [AirportDate] = '@airdate', [AirportHours] = @airhour, [AirportMinutes] = @airmin, ";
upd += "[Problems] = '@problems', [FirstDayActivities] = '@fdayact' ";
upd += "WHERE [UserID]=@usid";
OleDbParameter[] parm = new OleDbParameter[] {
new OleDbParameter("@pname",projname.Text),
new OleDbParameter("@pcode",projcode.Text),
new OleDbParameter("@cnt",countries.SelectedIndex),
new OleDbParameter("@startdate",datestart.Text),
new OleDbParameter("@finishdate",datefinish.Text),
new OleDbParameter("@totpart",totalparticipants.Text),
new OleDbParameter("@arrivedate",datearrival.Text),
new OleDbParameter("@airtran",RadioButtonList1.SelectedValue),
new OleDbParameter("@airdate",dateairport.Text),
new OleDbParameter("@airhour",airporthours.SelectedIndex),
new OleDbParameter("@airmin",airportminutes.SelectedIndex),
new OleDbParameter("@problems",problems.Value),
new OleDbParameter("@fdayact",firstday.Value),
new OleDbParameter("@usid",user.ID)
};
return (dal.UpdateRow(upd,false,parm));
}
/// 它不会导致异常,但返回 0 行受影响。当从 MS Access 中执行相同的查询时,它工作正常。因此,我认为问题在于参数的处理......但是什么?谢谢
Sergio:这样可以明确设置 OleDbTypes 吗?
///whatever ...
new OleDbParameter("@problems",problems.Value),
new OleDbParameter("@fdayact",firstday.Value),
new OleDbParameter("@usid",user.ID)
};
//then telling each one what they will be ...
parm[0].OleDbType = OleDbType.VarWChar;
parm[1].OleDbType = OleDbType.VarWChar;
///
return (dal.UpdateRow(upd,false,parm));