LINQ to SQL in vb.net- need help bad
Solved
Hi. I am fairly new to visual basic and know only a little about LINQ and SQL. I know how to select items from an array with LINQ, but what I can't figure out how to do is access a database using an IQueryable. I connected the database to my project, added two classes from the database to the "LINQ to SQL" .dbml file and saved it. In my programming assignment, I am not supposed to create a data source (table thing) to display the data, but update my own interface manually. In order to do it, I was told to instantiate this:
Private dogs As System.Linq.IQueryable(Of Dog)
(Dog is the class that I added to my .dbml file from the database file)
And somehow I am supposed to load database data from/using this. Help please if you can. I got screwed over by my professors as our online assignment program was down the whole thanksgiving break so I'm here doing this at the last minute. Thanks.
Ok someone on StackOverflow helped me. If anyone wants to know, you have to create a DataContext object that corresponds to the .dbml file (name it the name of the file + "DataContext" (in this case, DogsDataContext). Then you can write dogs = DogsDataContext.dogs.
Posted Dec 2, 2011, 4:22 AM UTC · edited