This may be a very simple fix, but I can't seem to figure this out. I have a query that pull data from a sql database and display it into a datagrid. When it does this, I also want to fill a textbox (txtTime.text) with the first row ("TIME_ID") from the datagrid. However, the query pull empty data, I get the index out of range error.
How would I set my syntax so that if datagrid is empty, exit the sub/function? I tried the following but no luck and still getting index out of range.
If datagridview1.Rows(0).Cells("TIME_ID").Value = "" Then
txtTime.text = datagridview1.Rows(0).Cells("TIME_ID").Value