Как получить данные внутри столбца из таблицы SQL server с помощью программы чтения данных VB.NET
Я пытаюсь получить данные из столбца [MorningTime-In], [Afternountime-In] в таблице Table_DTR . его тип данных-time(7), но я продолжаю получать сообщение об ошибке: System.IndexOutOfRangeExcemption:[MorningTime-In] .
Что я уже пробовал:
Dim timeInAm As DateTime Dim timeOutAm As Date Dim timeInPm As Date Dim timeOutPm As Date Dim xAm As Date = Date.Parse("08:00") Dim yAm As Date = Date.Parse("12:00") Dim xPm As Date = Date.Parse("01:00") Dim yPm As Date = Date.Parse("05:00") Try Connect = New SqlConnection(ConnectionString) Connect.Open() Dim dt = Convert.ToDateTime(DTRform.datetoday.Text) Dim id = Convert.ToInt32(DTRform.DTRempID.Text) Using Connect = New SqlConnection(ConnectionString) Connect.Open() Dim Query1 As String = "Select * From Table_DTR Where Date = @Date and EmployeeID = @EmpID" Dim cmd1 As SqlCommand = New SqlCommand(Query1, Connect) cmd1.Parameters.Add("@Date", SqlDbType.DateTime).Value = dt cmd1.Parameters.Add("@EmpID", SqlDbType.Int).Value = id Using Reader As SqlDataReader = cmd1.ExecuteReader() Do While Reader.Read() timeInAm = Reader("MorningTime-In").ToString() timeOutAm = Reader("MorningTime-Out").ToString() timeInPm = Reader("AfternoonTime-In").ToString() timeOutPm = Reader("AfternoonTime-Out").ToString() Loop End Using End Using