Solved

Find null dates in database

Posted on 2011-03-07
8
186 Views
Last Modified: 2012-08-13
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
Comment
Question by:Jpcoder
  • 4
  • 2
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35062827
Change line 14 to:

    If Me.RPDDataSet.Shift1.B2_1st_StartColumn IsNot DBNull.Value Then
0
 

Author Comment

by:Jpcoder
ID: 35069567
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
 
LVL 7

Expert Comment

by:foobarr
ID: 35112151
When you debug

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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Jpcoder
ID: 35133595
It returns {  } empty.

0
 
LVL 7

Accepted Solution

by:
foobarr earned 500 total points
ID: 35157208
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
 

Author Comment

by:Jpcoder
ID: 35169454
Ok that makes sense. I will give that a try on Monday (after the NCAA games) and let you know.
thanks
0
 

Author Comment

by:Jpcoder
ID: 35379956

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short film showing how OnPage and Connectwise integration works.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now