Z
zafi
Guest
Hi
I try to read the last line of data in database that I have using this codes
sql = "Select * FROM tableoptions"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "options")
con.Close()
'To check last rows
MaxRows = ds.Tables("options").Rows.Count
inc = -1
'To read the last row in database
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
TextBox1.Text = ds.Tables("options").Rows(inc).Item(1)
TextBox2.Text = ds.Tables("options").Rows(inc).Item(2)
TextBox3.Text = ds.Tables("options").Rows(inc).Item(3)
TextBox4.Text = ds.Tables("options").Rows(inc).Item(4)
TextBox5.Text = ds.Tables("options").Rows(inc).Item(5)
TextBox6.Text = ds.Tables("options").Rows(inc).Item(6)
End If
When i check the results, it didnt pick up the last row but still pick up the first line from the database. When I set the breakpoint, I can see the inc value on the row that I want to but the value from textbox1 - textbox6 is different.
I hope anyone can help me pertaining this matter.
Thank you all.
zafi
Continue reading...
I try to read the last line of data in database that I have using this codes
sql = "Select * FROM tableoptions"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "options")
con.Close()
'To check last rows
MaxRows = ds.Tables("options").Rows.Count
inc = -1
'To read the last row in database
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
TextBox1.Text = ds.Tables("options").Rows(inc).Item(1)
TextBox2.Text = ds.Tables("options").Rows(inc).Item(2)
TextBox3.Text = ds.Tables("options").Rows(inc).Item(3)
TextBox4.Text = ds.Tables("options").Rows(inc).Item(4)
TextBox5.Text = ds.Tables("options").Rows(inc).Item(5)
TextBox6.Text = ds.Tables("options").Rows(inc).Item(6)
End If
When i check the results, it didnt pick up the last row but still pick up the first line from the database. When I set the breakpoint, I can see the inc value on the row that I want to but the value from textbox1 - textbox6 is different.
I hope anyone can help me pertaining this matter.
Thank you all.
zafi
Continue reading...