var idKey = (from c in table1 // the table1 here has red line under it.
orderby c.IDKey descending
select c).First();
IDKeyField.Text = idKey.IDKey.ToString();
Thanks a lot for the quick response, I tried your code, but it is not working,
it does not recongnize (compile) "table1" , I think the entity object "db" must attach to it, but as I mentioned in my post, it compiled , but not return any thing.
as I mentioned in my post, it compiled , but not return any thing.
If a legal query is not returning anything, the next thing you should check is that the database table actually has data.
eric2820
Peter Cong
as I mentioned in my post, it compiled , but not return any thing.
If a legal query is not returning anything, the next thing you should check is that the database table actually has data.
The database base has data, I can see it from SQL Management Studio.
although there is no data return, but in the field of web form, the data shows somehting like system.blah.blah. it seems it return the C# source codes.
although there is no data return, but in the field of web form, the data shows somehting like system.blah.blah. it seems it return the C# source codes.
When I see a type name and not the contents of a type it is usually because I put a model entry in the View without prepending it with a @ symbol.
it does not recongnize (compile) "table1" , I think the entity object "db" must attach to it, but as I mentioned in my post, it compiled , but not return any thing.
Hi,
This error means that your edmx file doesn't have such an Entity class model called "Table1".
So please check whether your edmx file has these entity models.
var idKey = (from c in table1 // the table1 here has red line under it.
orderby c.IDKey descending
select c).First();
IDKeyField.Text = idKey.IDKey.ToString();
</div>
</div>
var idKey = (from c in db.Table1
orderby c.IDKey descending
select c).First();
IDKeyField.Text = idKey.IDKey.ToString();
Peter Cong
Member
527 Points
681 Posts
How to get the last record (row) from my SQL table,
Dec 21, 2012 01:02 PM|LINK
Hi, I have created an entityframework, I want to get the last record (one data) from my SQL table. but the Last() does not work,
Does anybody know how to make it working? thanks a lot,
yuvakom
Member
28 Points
47 Posts
Re: How to get the last record (row) from my SQL table,
Dec 21, 2012 01:31 PM|LINK
select top 1 from table name order by column name desc
Peter Cong
Member
527 Points
681 Posts
Re: How to get the last record (row) from my SQL table,
Dec 21, 2012 02:41 PM|LINK
Thanks for the quick response, is this the correct syntax? I tried it , it does not work, but no compile errors, no sure what is wrong.
var db = new Test1Entities();
var idkey = (from c in db.Table1
orderby c.IDkey descending
select c).Take(1);
IDKeyField.Text = idkey.ToString(); //this does not return the last key in the table.
Please let me know what is wrong with my codes, thanks again.
me_ritz
Star
9337 Points
1447 Posts
Re: How to get the last record (row) from my SQL table,
Dec 21, 2012 02:57 PM|LINK
var idKey = (from c in table1 orderby c.IDKey descending select c).First(); IDKeyField.Text = idKey.IDKey.ToString();Peter Cong
Member
527 Points
681 Posts
Re: How to get the last record (row) from my SQL table,
Dec 21, 2012 04:05 PM|LINK
eric2820
Contributor
2777 Points
1161 Posts
Re: How to get the last record (row) from my SQL table,
Dec 22, 2012 12:23 AM|LINK
If a legal query is not returning anything, the next thing you should check is that the database table actually has data.
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Peter Cong
Member
527 Points
681 Posts
Re: How to get the last record (row) from my SQL table,
Dec 22, 2012 12:35 AM|LINK
The database base has data, I can see it from SQL Management Studio.
although there is no data return, but in the field of web form, the data shows somehting like system.blah.blah. it seems it return the C# source codes.
eric2820
Contributor
2777 Points
1161 Posts
Re: How to get the last record (row) from my SQL table,
Dec 22, 2012 12:45 AM|LINK
When I see a type name and not the contents of a type it is usually because I put a model entry in the View without prepending it with a @ symbol.
http://www.my-msi.net/Admin
blog
If a post helps you, please mark it as Ansered, thank-you.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to get the last record (row) from my SQL table,
Dec 22, 2012 02:55 AM|LINK
Hi,
This error means that your edmx file doesn't have such an Entity class model called "Table1".
So please check whether your edmx file has these entity models.
Reguards!
me_ritz
Star
9337 Points
1447 Posts
Re: How to get the last record (row) from my SQL table,
Dec 22, 2012 03:44 PM|LINK
var idKey = (from c in db.Table1 orderby c.IDKey descending select c).First(); IDKeyField.Text = idKey.IDKey.ToString();