Solved

Find null dates in database

Posted on 2011-03-07
8
185 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 74

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

19 Experts available now in Live!

Get 1:1 Help Now