I am trying to assign to datetimepickers to new variables and am getting a null exception error when the last line below executes and don't know why?
However when I did it this way originally it worked fine?
Any clues please?
VB.NET:
Dim intSelectedTabPage As Integer
Dim dtmDateTimePickerFrom As New DateTimePicker, dtmDateTimePickerTo As New DateTimePicker
intSelectedTabPage = Me.tbcMain.SelectedIndex
dtmDateTimePickerFrom = DirectCast(Me.Controls("dtmFromDate" & intSelectedTabPage), DateTimePicker)
dtmDateTimePickerTo = DirectCast(Me.Controls("dtmToDate" & intSelectedTabPage), DateTimePicker)
taTableAdapter.SelectCommand.Parameters.Add("@from_date", SqlDbType.DateTime).Value = dtmDateTimePickerFrom.Value
However when I did it this way originally it worked fine?
VB.NET:
taTableAdapter.SelectCommand.Parameters.Add("@from_date", SqlDbType.DateTime).Value = Me.dtmFromDate.Value
Any clues please?