I'm trying to look at the last record inserted into a SQL table. I'm not getting an errors using the below code but cannot get text to appear in the textbox.
Thanks in advance
Protected Function getLastRec() As DataRow
Dim con As New SqlConnection(strcn)
Dim da As New SqlDataAdapter("select field from Table", con)
Dim ds As New DataSet()
con.Open()
da.Fill(ds)
Dim dr As DataRow = DirectCast(ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1), DataRow)
Return dr
t1.Text = dr.Item(0).ToString
End Function
Thanks in advance
Protected Function getLastRec() As DataRow
Dim con As New SqlConnection(strcn)
Dim da As New SqlDataAdapter("select field from Table", con)
Dim ds As New DataSet()
con.Open()
da.Fill(ds)
Dim dr As DataRow = DirectCast(ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1), DataRow)
Return dr
t1.Text = dr.Item(0).ToString
End Function