VB.NET: IF Else Query

Posted on 2008-11-10
Last Modified: 2012-05-05
Hi All,

I have a code below for VB.NET.

now is that i need to change my query that look like this.

if table mo_assembly = curdate() then 'Updated' Else 'Not-Up-To-Date'
if table mo_component = curdate() then 'Updated' Else 'Not-Up-To-Date'
if table mo_location = curdate() then 'Updated' Else 'Not-Up-To-Date'

same goes to all the other table

then from there i need to send a notification to admin that look like this

Table                                  Status
mo_assembly                     Updated
mo_component                   Not-Up-To-Date
mo_location                        Updated
mo_po_status                    Updated
mo_wo                               Updated
selling_price                      Not-Up-To-Date
Public Sub Checkdata()

        Dim sConString As String = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=; DATABASE=DUS; UID=root; PASSWORD=newpwd; OPTION=16834"

        Dim Conn As New ADODB.Connection


        Dim qryGetStatus As String = "select Name,DATE_FORMAT(last_update, '%Y-%m-%d') from backup where (name='mo_assembly' and name='mo_component' and name = 'mo_location' and name = 'mo_po_status' and name = 'mo_wo' and name='selling_price_financial_information_report') and DATE_FORMAT(last_update, '%Y-%m-%d')= curdate()"

        Dim rsGetStatus As New ADODB.Recordset

        rsGetStatus.Open(qryGetStatus, sConString, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, 1)


        If Not rsGetStatus.EOF Then




        End If

    End Sub

    Public Sub sendemailnotuptodate()

        'Dim send_email As String

        Dim mymail

        mymail = CreateObject("CDO.Message")

        mymail.Subject = "Waterfall & Loading Scheduler Report"

        mymail.From = "Item_Branch_Scheduler"

        mymail.To = ""


        'mymail.TextBody = "The Item_Branch data is not up-to-date. Please check from DUS/JDE database"

        mymail.Configuration.Fields.Item("") = 2

        'Name or IP of remote SMTP server

        mymail.Configuration.Fields.Item("") = ""

        'Server port

        mymail.Configuration.Fields.Item("") = 25



        mymail = Nothing

        mymail.TextBody = "The Item_Branch data is not up-to-date. Please check from DUS/JDE database"

    End Sub

Open in new window

Question by:bosscat
    LVL 32

    Expert Comment

    by:Daniel Wilson
    >>if table mo_assembly = curdate() then 'Updated' Else 'Not-Up-To-Date'

    I don't understand.  The table can't equal the current date.  A field in a record in a table can ... what field are you looking to compare to the current date?
    LVL 1

    Author Comment

    the field in the table is call last_update
    LVL 96

    Accepted Solution

    SQL Server and MySQL use the CASE statement.

    CASE Statement

    CASE case_value
        WHEN when_value THEN statement_list
        [WHEN when_value THEN statement_list] ...
        [ELSE statement_list]

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

    755 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

    21 Experts available now in Live!

    Get 1:1 Help Now