Link to home
Start Free TrialLog in
Avatar of KarlTheHopeless
KarlTheHopelessFlag for United Kingdom of Great Britain and Northern Ireland

asked on

how to list row data from sdf datbase

Hello Everyone

I am very new to databases.

Can someone please show me how to create a simple list of FirstNames (using visual basic and LINQ) from a connected sdf database

Thank you

Karl
Capture.PNG
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi KarlTheHopeless;

Because you are using a sdf datbase you can not use the ORM to create the DataContect mapping the the classes in code to the database. There seems to be a work around and the steps can be found here at SQL Server Compact and LINQ . Once you have the DataContext created the query would look like:

Dim context As New DataContext()

Dim fNames = (From f in context.BasicTable _
                          Select f.FirstName).ToList()

fName will now have a List(Of String) with FirstNames.

Fernando
Avatar of KarlTheHopeless

ASKER

Hi Fernando

That link does not work for me.

Have you any others?

I just tried it again and it is working for me. If it still not working do a google search on "SQL Server Compact and Linq". I have turned off my desk top and using a mobile device right now.
Hi Ferdinand

Yep, the link works now.

But I do not have the file SQLMetal.exe in the folder ...

C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\bin\

That file doesn't exist on my machine.

Earlier, you said that "Because you are using a sdf datbase you can not use the ORM to create the DataContect mapping ".

Well, should I try using a different kind of database to make life simpler?

I just want to create a simple database to reside on my local machine.

Nothing particularly fancy.

But, right now, it seems that I am already having to deal with "workarounds" before I even start!

Is this a typical Microsoft shambles, or have I missed something?

Do I really have to hunt around for 'workarounds' just to set up a new database?
Oops! I should have said Fernando.

Apologies.
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America 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
Brilliant!

Thank you.
Not a problem, always glad to help.  ;=)