I. Understanding ASP. NET Binding Database
Finally learned the connection database part of the content, Yang Zhengko teacher video looks very easy, if the HD version is more OK.
I found that I learn a new programming language will have a feature, all want to quickly learn the database, data is everything, have the data to operate all the reasons for it. Now it's very reassuring to be able to connect to databases. Record the process and become part of the learning trajectory.
Environment is VS2013, MSSQLSERVER (2012)
(a) I want to achieve the effect is: a drop-down menu DropDownList, from the database to get data from the side, displayed in the Order menu.
(ii) the process of realization
First, I've already built the database and the data sheet, as shown in.
1. Create a new Web Form file dropdownlist-sql.aspx
2. Drag a DropDownList control and select Edit Data source
Procedures for configuring data sources
The database connection string is then generated based on our configuration and saved to Web. config. The connection string is also saved in the new ASP. Net file that you just created. This process does not write other code except after the data source is edited. After all OK, just press F5 to run and see the drop-down menu displayed. Good convenience.
After the database is bound, viewing the aspx file in the design displays data binding. Such as:
(c) Compare the differences in the drop-down menu that PHP implements when querying data from a database
1, the implementation of the ASP. NET is a lot more convenient, just need to edit the data source, you can let the data bound in the drop-down menu.
2, PHP Implementation of this, the first is to use mysql_connect () "Connect the database", then the Code database "query statement", finally get an "array", and then through a For loop each item item output in the Foreground drop-down menu. Each step is to achieve their own, unlike ASP., click a little mouse, complete.
[digression: Learning one weeks of the net, the biggest experience is a hand to constantly touch the mouse, because always points ah point, overall OK. ]
Understand the DropDownList edit data source in ASP. NET, bind database data.