Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15067

VS 2017 Return Minimum Date from SQL db

$
0
0
Hello:

A bit old school with great intentionality. Can someone please tell me how I would return the MinDate in this function?

Code:

    Private Function GetEarliestStartDate(ByVal _opcheck As String) As Date
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset

        Dim sql As String = "SELECT MIN(StartDate) AS MinDate FROM Schedule " &
                            "WHERE WorkCenterID = '" & _opcheck.Trim & "' " &
                            "AND ScheduleID = '" & cboNewScheduleNo.Text & "' "

        cn.Open(connectionString_Read)
        rs.Open(sql, cn, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockReadOnly)

        rs.MoveFirst()
        Return (rs.Fields("MinDate"))

        rs.Close()
        rs = Nothing

        cn.Close()
        cn = Nothing

    End Function

Thank you!

Viewing all articles
Browse latest Browse all 15067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>