Link to home
Start Free TrialLog in
Avatar of stracqan
stracqan

asked on

How do I access the data in my database variable in .NET & C#?

Hello,

I'm new to .NET and I have been following the tutorials on the ASP.NET site for MVC 3 Apps using C#.

Everything is going smoothly but now I need to customize things and I'm stuck.

I have a variable set up that pulls data from my databases, which is then stored as an object.

I simply want to loop through that data set and pull out the column values individually.

Check out my code for a better explanation.

Thanks!!!!!!!!!
//in my controller

//this is an object that has two child objects
//that correspond to 2 tables in my database
//those child objects have all the column names
BookStoreEntities db = new BookStoreEntities();

 public ActionResult GetList()
        {
            //get all data from the BookList Table
            var booklist = db.BookList.ToList();

            //loop through each book and get the data
            //this is where im lost... Not sure how to get
            //to the Book Title etc...
            for (int i = 0; i < booklist.Count; i++)             {
                     //in here is where i want to access
                     //each columsn data and do something 
                     //with it...
                     //i tried:
                     var title = booklist.BootTitle(i);
                     //to no avail..
                 }
             }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BurnieP
BurnieP
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dmitry G
It seems you do everything OK, just confused with a collection:

                   
                   
var title = booklist[i].BootTitle;

Open in new window

Ooops... Same as BurnieP... :) Didn't see
Avatar of stracqan
stracqan

ASKER

Thanks!