I am trying to pull values from a specific row with a select stmt in a database so I can set some variables. However, my code is not grabbing the value and I am getting the error "Index was outside the bounds of the array". I am not sure what is wrong.
Can someone please tell me what I am doing incorrectly? Is my Select stmt wrong? Is there a better way? Thanks
VB.NET:
conn = New OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0; data source=c:\PR\Payroll.mdb")
Try
da = New OleDbDataAdapter("SELECT * FROM Hours", conn)
myDataTable = New DataTable
da.Fill(myDataSet, "Hours")
Catch ex As Exception
Console.WriteLine("Error Opening {0}", conn.DataSource)
EndTry
myCommand = New OleDbCommandBuilder(da)
'covert Today() to string and parse just the date to enter in database
Dim dateStr AsString = Today().ToString
Try
dateStr = FormatDateTime(dateStr, DateFormat.ShortDate)
Catch exp As Exception
MsgBox("Date not valid date format")
EndTry
Dim foundRows() As Data.DataRow
foundRows = myDataSet.Tables("Hours").Select("TodayD Like '" & dateStr & "' AND EmpNum Like '" & globalEmpNum & "'")
'ERROR IS HERE
globalTodayDate = foundRows(0).Item("TodayD") 'text type from database
globalTimeIn = foundRows(0).Item("TimeIn") 'date type from database
EndTry
Last edited by a moderator: