Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to list row data from sdf datbase

Posted on 2011-02-22
8
701 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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 setup several different housekeeping processes for a SQL Server.

829 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