Click to See Complete Forum and Search --> : How I can Find Out The Last Value In tables Column?


Isha
May 29th, 2003, 06:10 AM
Hi Buddy

Can anyone tell me how I can find out the last record from the Employee table's EmployeeId column.?

I declare:Imports SDO=System.Data.OLEDB
When I use this statement:
If Me.Databinding(DS,"Employee").Rows.Count then
Me.Databinding(DS,"Employee").position= Me.Databinding(DS,"Employee").Count-1
end if

It Shows me tha last record on textboxes.But If I want To Store This Procedure In a variable.It Shows False Result.Can U Tell me
How I can Store the last record in the Employees table's EmployeeID Column.?

My Thecnique is that:
Bcz If The Data is not in the table It will show the 1 in TxtEmpId.Text
Else
If the table contains data then It take last record from EmployeeID column and add 1 to it for new entry.
I hope u will understand my poroblem.
I will be thankful to u.........................
God Bless You.



:)

Gizmo001
May 29th, 2003, 01:53 PM
if EmployeeID is in column 3, for example, and you want to store the value in variable 'x' then you can use one of the following

x=convert.tostring(Employee.rows(Employee.rows.count-1)(2))

or

x=convert.toInt32(Employee.rows(Employee.rows.count-1)(2))

or

x=Csng(Employee.rows(Employee.rows.count-1)(2))

Hope this is what you were looking for.