Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Find null dates in database

Here is a sample of my Db                                                                                  Database sample
Ok, here is what Im trying to do.  

•      Select Date on Monthly Calendar

•      Fill text box with selected date

•      Fill Data table adapter with data from selected date (4 row)

•      Make green button visible if valid date in row is (not null, date is same as selected
Date (time is diff) else not visible.

•      Display selected date (no edit)

•      Display the Data table adapters data from selected date (4 rows) with Show-Up-Down  for time of day

I need to have the button change color if there is a null in the selected row.

Here is some of my code.

Public Sub MCal_MachSch_DateSelected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MCal_MachSch.DateSelected
        
TxtBxSelectDate.Text = e.Start.ToShortDateString()
 
   End Sub

Private Sub BntSelectDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BntSelectDate.Click
        Refresh()
        
Try
           
            Me.Shift1TableAdapter.Fill(Me.RPDDataSet.Shift1, Me.TxtBxSelectDate.Text)
 
            If (Me.RPDDataSet.Shift1.B2_1st_StartColumn.ToString) IsNot DBNull.Value Then
                Me.Bnt_B2_1st.Visible = True
            Else : Me.Bnt_B2_1st.Visible = False
            End If
     End Sub

Open in new window

app sample
0
Jpcoder
Asked:
Jpcoder
  • 4
  • 2
1 Solution
 
käµfm³d 👽Commented:
Change line 14 to:

    If Me.RPDDataSet.Shift1.B2_1st_StartColumn IsNot DBNull.Value Then
0
 
JpcoderAuthor Commented:
I changed line 14,
but  Me.Bnt_B2_1st.Visible = True  stays True even when the value is null.
Is that a problem in the table adapter?
0
 
foobarrCommented:
When you debug

What does Me.RPDDataSet.Shift1.B2_1st_StartColumn.ToString() return when it reaches a null date?

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JpcoderAuthor Commented:
It returns {  } empty.

0
 
foobarrCommented:
If String.IsNothing(Me.RPDDataSet.Shift1.B2_1st_StartColumn.ToString) = False Then
                Me.Bnt_B2_1st.Visible = True
            Else : Me.Bnt_B2_1st.Visible = False
            End If


basically instead of checking if the DBNULL, check to see if the string is nothing
0
 
JpcoderAuthor Commented:
Ok that makes sense. I will give that a try on Monday (after the NCAA games) and let you know.
thanks
0
 
JpcoderAuthor Commented:

Ok , when I ran this it gave me the column header instead of the date in the cell
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now