private 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中执行相同的查询时,它可以正常工作.因此,我认为这个问题与参数的处理有关......但是什么呢?谢谢
塞尔吉奥:这是否可以,明确设置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));
Nelson Reis.. 6
检查是否正确设置了user.ID的值.
在您的upd命令字符串中,您使用引号包围参数,如下所示:
[StartDate] = '@startdate'
删除所有参数中的引号.
检查是否正确设置了user.ID的值.
在您的upd命令字符串中,您使用引号包围参数,如下所示:
[StartDate] = '@startdate'
删除所有参数中的引号.