Talk about the sad journey from hotel services to the IT industry, with my book ASP. NET (C #) to implement registration and login functions with SQL Server

Source: Internet
Author: User

The landlord I surname Zhou, name xx, hometown is Zeng Guofan's former residence, said and the ancients also is neighborhood neighbor.

92 births, last year's college graduation, to now graduate nearly a year, the University of Professional is hotel management, we declared as "tertiary industry" hehe. Here you may have a question, why the university has a "hotel professional", how can you choose it? Speaking of this, the landlord had to mention a person, that is my cousin, the landlord to fill a volunteer that year, people small not sensible, do not know how to choose their own professional, the family is even more do not understand, so fill the volunteer thing in my cousin in the hands of the Lord, fill the school is Hunan Changsha, three years of great autocracy, Because my cousin is in Changsha Zhongnan University of Forestry Science and technology teaching, and my this school is just next to their school, so he helped me choose this school, and filled out this hotel professional, Dad is also obsessed listened to her arrangement, also encouraged me to read this major, the back of the thing is to fall into this pit, I still remember the first time on the practice class, the school to each person sent a set of waiter clothes, and then we are dozens of fools like a fool in the room to practice the end plate, serve, to the last semester, we have to test the relevant documents, when the test, the teacher told us as long as you have done, to pass and issued a diploma, At that time, I was the first in our class to oppose the people, I am very clear that this is the school changed tricks to collect money, so perfunctory quickie, not to earn students money can do? Where's the head of the industry's spiritual conscience?

Rogue a slap does not sound, to the final landlord or choose to compromise, followed by the 800 of the ocean, we got a paper technical certificate, the above marked the junior technician, Pit Daddy Ah, now back to think, the heart unavoidably to my that cousin produced suspicion: Is she with me this school has the enrollment cooperation relationship, I have received my poll tax, who knows, this is something, for the moment not the table.

Said the landlord is the hotel management major, after graduation, first went to the Changsha local telecommunications Bureau, do is the telephone sales landlord quirks has gone to the front desk of two hotels, all day to move the table, serving what, everyone do not think that the hotel management, out can be a supervisor, in fact, What I learned in school is not enough to see, we also know that China's education model to now is still biased in theory, practice, far from the development of society, do not know what the society needs what kind of skills and talents, which makes every year a lot of college students can not find a job at the time of graduation. , alas, what else can we do with our dissatisfaction with the other people who spit on the micro blog? We are only a medium of anger! Oh, a bit off the topic, I said in front of the two have gone to the hotel, in short, dry half a year of hotel work, the landlord tired of the heart, why do you say so? Hotel Services Night is the most exhausting people's lives, the first working environment is not good, every day in the water stains, oil, smoke in the harsh environment, the whole image of the temperament Berthelot off a clay turtle, the two is that this is not the work of the landlord want, Sometimes see our department and add some new 66-year-old younger brother I feel sorry for them, so in quit before the landlord has been on the internet to find a variety of career change work, at the beginning of the beginning, I also met a lot of career change people encountered problems: that is, what to do? In addition to this profession, the other himself has not touched, what can I do?

Talk about me now, the landlord is now engaged in the IT industry, the main dotnet technology; Of course, this blog park I also have prepared to come, all again dedicated to my my book, to treat you, hope you are generous enlighten.

Most of the work in the world is a skilled job, programming is no exception, do long, do more, natural also pass!

As a programmer, to have a programmatic thinking, this thinking is not 352 days can be overnight, it is a continuous accumulation of the process, like discovering, do not only to grasp the law, but also hold a cautious attitude, convergence, and in the use of law, but also to repeat the practice, Pao "Thousands of cattle to" the same, keep repeating, will eventually realize the truth of things. Therefore, as a novice programmer, it is more necessary to accumulate their own code through a lot of code practice.

Well, there's not much to gossip about. Go directly to our today's topic ———— ASP, and use SQL Server to implement registration and login features!

First of all, see the topic to clarify the idea, the first step to do what, the second step to do what, what is the intrinsic connection between them.

Steps:

In the first step, we use the SQL language to build the database Registlogin, the data table user, and create the constraint relationship and insert the test field (this step is simple, omit the process)

In the second part, we open vs connect to the database, the operation flow is shown in figure:

First we find the view in the VS Menu section, click Server Explorer

When you click Server Explorer, the interface appears as follows:

Then appears:

By this step we have completed the connection to the database:

Next, we are going to register in VS, the registration operation is simply to insert data into the database, so we create a window application body, add the appropriate control

Inserting Data codes

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceDatabase Validation { Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }               Private voidBtnzhuce_click (Objectsender, EventArgs e) {            stringSQL ="Data Source=.;i Nitial Catalog=registlogin; User Id=sa; Password=123"; using(SqlConnection Scon =NewSqlConnection (SQL)) {                stringstr ="INSERT INTO [User] (Username,userpwd, useremail, Userphone) VALUES ('"+ TxtUserName.Text.Trim () +"', '"+ TxtPwd.Text.Trim () +"', '"+ TxtPhone.Text.Trim () +"', '"+ TxtEmail.Text.Trim () +"')"; Scon.                Open (); SqlCommand Command=NewSqlCommand (); Command. Connection=Scon; Command.commandtext=str; intobj=command.                                             ExecuteNonQuery (); MessageBox.Show ("Registration Successful"); Form2 F=NewForm2 ();                        F.show (); }                    }    }}

Then create a login form in the same solution:

The login operation is simply to retrieve the data in the database exists, the code is as follows:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namespaceDatabase Validation { Public Partial classForm2:form { PublicForm2 () {InitializeComponent (); }        Private voidBtnlogin_click (Objectsender, EventArgs e) {SqlCommand sqlcmd=NewSqlCommand (); stringStr="select*from user where username= '"+ Txtadmin. Text. Trim () +"' and userpwd= '"+ txtpwd. Text. Trim () +"'"; Sqlcmd.commandtext= str;//Execution DataSqlDataReader Sqlread = sqlcmd. ExecuteReader ();//reading Data            if(Sqlread.read ()) {MessageBox.Show ("Landing Success!"); }           Else{MessageBox.Show ("The user name or password is wrong! "); }                    }           }}

The above is all the process, if there is a mistake, but also hope that you more advice!

Thank you!

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.