亚音速2.2。我使用存储库记录模式,其中有一个表“appointment”,其中appointmentid为自动递增int。
我正在尝试更新它,但是当我用完全不同的内容更新字段时,脏列总是零,我得到一个异常。
System.NullReferenceException:对象引用未设置为对象的实例。位于subsonic.subsonicrepository.update[t](repositoryrecord)的subsonic.dataservice.executequery(querycommand cmd)
1 item, String userName) at janji.Janji.Data.DB.Update[T](RepositoryRecord
1项)位于a:\source\vs2008\web\apps\janji\janji\classes\dal\allstructs.vb:line 197 at janji.webform4.savedata()in a:\source\vs2008\web\apps\janji\janji\ui\appt.aspx.vb:line 343
以下是我的代码:
Try
If Appointment.AppointmentId > 0 Then
Appointment.AddressName = uxHotel.Text
Appointment.Address = uxAddress.Text
Appointment.AppStartTime = Date.Parse(uxApptDate.SelectedDate.Value.ToShortDateString + " " + uxApptStartTime.SelectedDate.Value.ToShortTimeString)
Appointment.ApptEndTime = Date.Parse(uxApptDate.SelectedDate.Value.ToShortDateString + " " + uxApptEndTime.SelectedDate.Value.ToShortTimeString)
Appointment.Completed = uxCOmpleted.Checked
Appointment.DropNumber = uxDropNum.Text
Appointment.Total = 0
Appointment.EmployeeId = 0
Appointment.Model = uxModel.Text
Appointment.DropAmount = Decimal.Parse(uxDropAmount.SelectedValue)
Appointment.RoomNumber = uxRoom.Text
'If Appointment.DirtyColumns.Count > 0 Then
Janji.Data.DB.Update(Of Janji.Data.Appointment)(Appointment)
'End If
End If
Catch ex As Exception
_ErrorMessage = ex.ToString
RetVal = False
lErrors.Text = _ErrorMessage
lErrors.Visible = True
End Try