Since WPF is now the most advanced Windows platform GUI technology, it is necessary to learn a little bit for the convenience of writing small programs.
First to find a tutorial step by step, so Baidu to the WPF Introductory Tutorial series (a). Looks like this tutorial only the first period Ah, regardless of this, do it first.
First want to install vs2013 Community Edition, but the computer is pirated WIN7, non-SP1, update SP1 also unsuccessful, installed VS2010, can use it.
Here's the start.
First Open VS, Create a C # program, choose WPF, and that's not much to say. Follow the WPF Introductory Tutorial series (a) to do it, until
WPF Background Logic Code writing
This step. Since the database has not been learned, the installation of the database is a half-day.
Installation of the database:
After loading the vs2010 there will be sql2008 this Start menu item (of course, to choose when installing). Open the SQL Server installation Center, select the first item in the installation, and specify the SQL 2008 installation disk (ISO file) to configure.
After the configuration should be prompted to restart, after the installation process there is nothing to say, be sure to select the installation management tools. Identity authentication I chose to use Windows authentication. Then there is a step to choose or set the user name or something, it is easy to error. There select the dot triangle to choose NT authority\localservice on it.
After the installation is complete, open SQL SERVER Management Studio, which appears
Here the direct point connection may not be connected, we need to open the Configuration tool in the SQL Server Configuration Manager settings. Open the left to select the SQL Server network configuration, select your server (XX protocol), the right side will appear TCP/IP and other settings.
Right-click TCP/IP properties, find IP3 and IPALL, set by diagram (why so set, I also say not clear)
Then go to studio and the server name setting (local) can connect to the local database.
At this point the left side can see the local database situation.
In order to match the previous WPF program, we need to AdventureWorks this database (in fact, this is the sample database that can be selected at the time of installation). Create it here, you can right-click the database, select New database, all by default set the line, you can also new query, with SQL statement
DATABASE AdventureWorks
Then refresh the database and you will see the Adventrueworks database. Click to open it, right-click Table, New Table
The next step is to set it up in the fields required by the program.
Here you need to set a primary key (right-click Settings), rather than set the ID bar, if not set up after the WPF program to connect to the database will be error.
After the table is set up, right-click on the table, select Edit the first 200 lines, we can add test data inside. The part of the database is over.
Continue to write the program
Then continue to follow the tutorial, you need to pay attention to
New SqlDataAdapter ("select contactid,firstname,lastname,emailaddress from Person.Contact where ContactID <=100; ", conn);
This sentence, I am running the error here, the SQL statement has a problem. I write
New SqlDataAdapter ("select * from adventureworks.dbo.[ Person]", conn);
Yes, my table name is person.
After continuing with the tutorial, the whole program will run correctly.
That's awesome!
WPF Learning (i): First WPF program (contains database SQL Server 2008)