Click here to Skip to main content
15,891,993 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
VB
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
            Console.WriteLine(MaxPass)
        Next

    End Sub
Posted
Comments
[no name] 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

This[^] might be one way you can do it.
There is also this[^] way.
 
Share this answer
 
Comments
Gerald Connolly 16-Oct-12 16:15pm    
Sorry you have completely missed my obsure point see above
fjdiewornncalwe 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 http://visualbasic.about.com/od/usingvbnet/a/LINQtoSQL.htm, 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900