TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abdullah Zafar
NA
4
3.2k
C#, Restful Web Api on MVC4
Feb 14 2014 1:13 PM
i am new in c#, and making a Restful API on MVC4,
i am using following code and gets an error on
"
foreach (DataRow menuDR in menuDataSet.Tables [7].Rows)"
IndexOutOfRangeException was unhandled by user code, and in details in show "cannot find table7"
i used the same approach with 1 table database and it was working, i don't know how to handle this exception and tried various things to get it sort....
public IEnumerable<RestaurantsMenu> GetAllMenu()
{
menuCon = new SqlConnection ("Data Source=MyPc\\MyPc;Initial Catalog=MENU;Integrated Security=True");
menuDataAdapter = new SqlDataAdapter (" SELECT * FROM RestaurantsMenu ", menuCon);
foreach (DataRow menuDR in menuDataSet.Tables [7].Rows)
{
Rst_Menu.Add(new RestaurantsMenu(){Restaurant_ID = int .Parse (menuDR[0].ToString()), RestaurantName =menuDR[1].ToString(),
Menu =menuDR[2].ToString(), Price=int .Parse (menuDR[3].ToString()) } );
}
return Rst_Menu;
}
Reply
Answers (
1
)
simple issue ? Windows forms ..
Write Text file with delimiter