Solved

how to list row data from sdf datbase

Posted on 2011-02-22
8
690 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 62

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 62

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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

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

Apologies.
0
 
LVL 62

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 62

Expert Comment

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

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now