Old Programmers Learn C # (i)------First Knowledge C # Visual Studio 2008

Source: Internet
Author: User
Tags microsoft sql server management studio sql server management sql server management studio

Background: An old programmer, has ten years of experience, dare not to say proficient, but can be skilled vb/vc++, other java/pascal and other languages are slightly known, now because of project needs, but also with the times, began to learn the C # language, platform using Visual Studio 2008.

Perhaps a lot of programmers are such a similar background, so here I do not want to C # from too basic (such as data type, etc.), there is a foundation, we play the language directly from the realization of the application, and then to the in-depth steps. Of course, from the realization of the application of the road is very short, perhaps you will be in 10 minutes to write a student management system in C #. Oh, let's get started.

Environment: Visual Studio 2008+sql2005 Express

Installing Visual Studio 2008 It's not hard, it's OK to go next.

After the default installation, there will be only a SQL2005 database, and no express for management. So you also need to download a SQL Server Management Studio Express tool. Once installed, you can use it to manage the database.

The difficulty here is that the SQL2005 default settings cannot enable remote invocation , so you can only invoke the database on the native port, and if you want to do so remotely, you need to set up a bit.

The error prompts appear as follows:

2, enable SQL Server Browser: If the server does not have SQL Server Browser enabled, in the above window, select SQL Server Browser and choose Start.

3, configure the SA user password: Open the installed SQL Server Management Studio Express, choose "Windows Authentication" to connect to the database, select the "Security" section, select "Login name", double-click "sa", and then display the window , configure the SA password.

4, firewall related port settings can refer to the different desktop firewall instructions.

The first example: "Hello world." ”

Open Visual Studio 2008, and the first time you open it will show you the choice of locale, choose "C #" and choose "New"----"Project"-----------"Windows-----Windows Application", name and solution added yourself, Can be written "hellotest", OK. Open the following interface:

The interface is nothing special, the left tool control, the right file explorer and attributes, the old programmer to see it, not much nonsense.

Add a Label control, and then double-click the window to load the Load event. Write the code as follows:

Run, you will see that the value of Label1 is Hello world!.

Well, the original is so, the old programmers think this is a mixed version of VB and VC, VB features are easy to see, and the characteristics of VC is to see the code:

Namespace Hellotest

{

public partial class Form1:form

{

......

}

}

Class, as long as it is about C, it must be related to class, so there are classes have VC + + shadow, of course, in the closing sentence ";" The time has felt the VC. First of all, we'll look at it later.

Label1 properties can be arbitrarily changed, the window Form1 properties can also be arbitrarily changed.

Try other grammatical changes:

Copy Label1, paste, found no hint to set up control group, oh, convenient.

Add a button control and a Timer control, double-click,

The code is written as follows:

private void Button1_Click (object sender, EventArgs e)

{

string t = "Hello world!";

Label2. Text = t;

Assign the contents of the Label1 to 9

int i;

for (i = 0; i < i++)

{

Label1. Text = i.ToString ();

}

Start the timer.

Timer1. Start ();

}

private void Timer1_Tick (object sender, EventArgs e)

{

0 o'clock on duty, stop timing

if (int. Parse (Label1. Text) >0)

{

Label1. Text = (int. Parse (Label1. Text)-1). ToString ();//int. Parse () is a function of the string int, and an int. TryParse ().

}

Else

{

Timer1. Stop ();

}

}

The definition variable and VC are the same, the data type is also largely unchanged, IF, for statement syntax and C + +, so imagine other while, switch, etc. should be the same.

Well, the old programmer won't waste too much time on this, he wants to get into the most practical applications quickly. (Note that this is not a purely grammatical place to teach you how to get into the development situation quickly.)

After testing, generally need to follow the steps to configure:

1, configure the remote connection on the SQL2005;

2, enable SQL Server Browser;

3, configure the SA user password;

4, verify that the firewall does not block the relevant ports.

The specific configuration is as follows:

1, configure enable remote connections on the SQL2005:

Start---program----Microsoft SQL Server---------Configuration Tool----------------SQL Server perimeter application configuration. After you open the interface, select the services and connections perimeter configuration, and under Database Engine have a remote connection, select local and remote connections, and the protocol is best to use both TCP/IP and named pipes. Then select "Services" and choose "reboot".

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.