Solved

Find null dates in database

Posted on 2011-03-07
8
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 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