Warm congratulations on this series of tutorials finally entering the main topic of vs2005. Some friends have always said that this tutorial of mine is not a vs2005 tutorial at all, so I have nothing to say. But I hope my friends will understand that if there are no languages such as c#, j#, and vb.net, Support, what is the use of vs2005???????
If you want to make a web page, just learn DW directly. Why use VS2005? In terms of web page layout, this is more difficult to use than DW. I am not saying that this is not possible, but it is definitely not as easy to master as DW.
Okay, let’s get to the point. Database aspect There are quite a lot of things, so I plan to start with the database control, and then use the database control to implement it in subsequent examples. If necessary, it will involve DataSetDataAdapter, etc. After learning the control, there will be a special database application chapter. I hope you all understand!!
First of all, of course, the most... most... most commonly used one, SqlDataSource, which can easily complete data query and display without writing or writing very little code in conjunction with the data sending and display control. Of course, he also supports interaction with any database supported by ADO.NET, including Microsoft SQL Server and Oracle databases, as well as OLE DB and ODBC data sources. At run time, the SqlDataSource control automatically opens a database connection, executes a SQL statement or stored procedure, returns the selected data (if any), and then closes the connection.
We first have to talk about the database connection string. In the past, when we used vs2003, we could only write the connection code manually. Now with this control, we can automatically add the connection string to web.config.
Writing the code into web.config is It’s a ridiculous thing to say. If it’s written in the code, it would be very miserable. People can find your database information from the code. Remember, there is a method of hacking the server called injection, right? Hehe, I’m sorry, I used to I have hacked several servers through SQL, but that’s because I am bored running an Internet cafe. I have learned programming in the past two or three years and have no time to do it. So I almost forgot SQL... Let’s continue with the topic. Let’s use it to build Connect a database, and then use a gridview to see the results! Gridview related skills will be discussed in a special chapter, here they are just a supporting role.
The example we are going to do below is very simple. First, use a Gridview to display data on the page and implement deletion, and then use detailsview to display a single piece of data from the parameters passed by the Gridview!