Solved

how to list row data from sdf datbase

Posted on 2011-02-22
8
698 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:KarlTheHopeless
  • 4
  • 4
8 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 34958269
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
0
 

Author Comment

by:KarlTheHopeless
ID: 34958377
Hi Fernando

That link does not work for me.

Have you any others?

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 34958437
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.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:KarlTheHopeless
ID: 34958522
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?
0
 

Author Comment

by:KarlTheHopeless
ID: 34958602
Oops! I should have said Fernando.

Apologies.
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 34963136
Hi KarlTheHopeless;

To your question, "Well, should I try using a different kind of database to make life simpler?", I would be simpler if you were to use SQL Server Express it is free and can be downloaded from [HERE]. There should be no work around then.

Here is a link to Using LINQ to SQL (Part 1) by ScottGu which will show how to set up the data context he also has a link to a video he made. He has many post by the same name just change the part number.

Fernando


0
 

Author Closing Comment

by:KarlTheHopeless
ID: 34964164
Brilliant!

Thank you.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 34964814
Not a problem, always glad to help.  ;=)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question