Click here to Skip to main content
13,054,779 members (75,283 online)
Rate this:
Please Sign up or sign in to vote.
I am trying to use VB (VS2010) and SQL Express 2013.

I am using WPF as the presentation layer, but i am not Binding to the fields (mainly cuz i cannot get my head round that) and i do NOT want to go that route with this app.

The problem i am having is that i cannot find any simple examples of what i need to do to make this combination work. I have managed to build a simple console app, but as soon as start building a WPF app it all changes, what do i have to do to convert.

This works for a console app
Sub Main()
        Dim db As New DataClasses2DataContext("Data Source=HPUG-GAC\SQLEXPRESS;Initial Catalog=MaxGate;Integrated Security=True")
        Dim passQry = From pass In db.Passes Select pass.PassID, pass.First_Name, pass.Last_Name
        For Each MaxPass In passQry
    End Sub
Posted 16-Oct-12 3:08am
Wes Aday 16-Oct-12 9:24am
Okay so what is it that you want to do instead? There is no console to write to in a WPF app. Otherwise, it would be exactly the same...
Gerald Connolly 16-Oct-12 16:14pm
Sorry the console bit is a red herring.

When i don't get when i add a datasource to my WPF project is that i don't get the DataContext class etc that i get with my console project, is it just that i am missing a step?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This[^] might be one way you can do it.
There is also this[^] way.
Gerald Connolly 16-Oct-12 16:15pm
Sorry you have completely missed my obsure point see above
Marcus Kramer 16-Oct-12 16:30pm
I think I did. In your WPF application the Console stuff won't work, but it will in a traditional Console application. You either have to bind the values to a ListBox control(or anything that can accept the IEnumerable), or you have to do something like the links I gave you do and create your own Console like window.
Gerald Connolly 16-Oct-12 17:16pm
So i have narrowed it down.

If i use a VB console project when i add a LinQ item to my project it automatically generates all the classes i use in the example.

But when i do the same thing in a WPF project it doesnt generate the classes.

Incidentally i am following this example, but i want to use WPF as the presentation layer as i have already designed all my screens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 16 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100