3 Replies - 404 Views - Last Post: 26 November 2013 - 09:09 AM Rate Topic: -----

#1 Exceedinglife  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 01-July 12

WPF Main method

Posted 25 November 2013 - 06:24 PM

hello all,
In a windows form c# project im making myself a shopping program. I am making this program from scratch to practice my programming skills. I really want to keep practicing my programming to get better and i know the only way to get better is to keep going it, reading about it, and watching movies on it. I just made myself a database and the one i choose is SQLServerCe. In a windows form you add code in the Main() this is an example that i got to work in my windows form
        static void Main(string[] args)
        {

            List<string> myList = new List<string>();

            // Retrieve the connection string from the settings file.
            // Your connection string name will end in "ConnectionString"
            // So it could be coolConnectionString or something like that.
            string connString = @"Data Source=dataname.sdf";

            SqlCeConnection conn = new SqlCeConnection(connString);
            conn.Open();

            SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Test", conn);
            SqlCeDataReader reader = cmd.ExecuteReader();

            while (reader != null && reader.Read())
            {
                //Console.WriteLine(reader[0]);
                myList.Add(reader[0].ToString());

            }
            conn.Close();

            foreach (string s in myList)
                Console.WriteLine(s);

            Console.WriteLine("the end");
            Console.ReadLine();



This reads the data to the console of a table i made in my database.

My question is i want to make a WPF Project and u dont know how to set this up. I made the SQLServerCe in WPF but i dont have a main to read the tables i make and im going to make the CRUD methods for my SQL database for my WPF project for adding a customer and saving it.

Thank you for your time.

Is This A Good Question/Topic? 0
  • +

Replies To: WPF Main method

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5481
  • View blog
  • Posts: 11,762
  • Joined: 02-June 10

Re: WPF Main method

Posted 25 November 2013 - 07:00 PM

Check my signature block. There are two tutorials for the WinForms coder transitioning to WPF.
Was This Post Helpful? 1
  • +
  • -

#3 Exceedinglife  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 46
  • Joined: 01-July 12

Re: WPF Main method

Posted 25 November 2013 - 07:36 PM

View PosttlhIn`toq, on 25 November 2013 - 07:00 PM, said:

Check my signature block. There are two tutorials for the WinForms coder transitioning to WPF.


Thank you i will check it out.
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4469
  • View blog
  • Posts: 7,780
  • Joined: 08-June 10

Re: WPF Main method

Posted 26 November 2013 - 09:09 AM

Quote

In a windows form you add code in the Main() this is an example that i got to work in my windows form


I'm seriously confused as to what you're trying. You have a "Windows Forms" project, but you're doing everything in the Main method and outputting to the console, not any form controls. That's not exactly the ideal way to do WinForms. And it's certainly not the way to do WPF. It's too complicated to go into in a reply, but you really should read tlhIn`toq's tutorial. Not just that one, but many of his tutorials, because he's got a lot that explain in-depth how to make GUI-driven applications for both WinForms and WPF.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1