ASP.net Our previous chapters describe how to display information in a database and the basic usage of DataReader and datasets.
Have a friend say not enjoyable, want me to write the following chapter quickly, very sorry, I really do not have much time, write this
Some are very slow. (Don't throw eggs, at most I don't talk nonsense)
Let's talk about DataSet here, this is a powerful stuff, we have a in the last section
Preliminary understanding, here we want to talk about it if used to manipulate the data. is also very simple dongdong, but the function is formidable, must
It's not possible, because the dataset and DataGrid controls account for more than 50% of. Net Help, and this
A total of 23M ...
Here we set up a Test.mdb database as a test database, with a table named ASPCN, with a number
According to the structure as shown
Figure 8-1
A database operation without a dataset
Before we use the dataset, let's take a look at how to insert a database without using a dataset in asp.net.
Update, delete.
To insert, UPDATE, delete data without using a dataset, there is no way, only SQL directly come:
, I'll just talk about how to insert, because the other operation is only to change the SQL statement, I think we have no problem
it. Because of the use of the MDB database, this will be done with ado.net.
The data we submit to the database comes from the user input, which uses a <form> that we often see
The form, the junior look and normal is no different, but we carefully look at its <form> in the properties of what, RU
nat= "Server", hehe, is such a small label, the nature of this program has changed. This shows that he is a
Web Form. Here I used HTML controls to show you how asp.net and ASP
Some difference.
In the code above, one thing to note is that the Trigger button control commit event is handled by OnServerClick
, there is little attention here, because everyone uses the Web control has become a habit, it is easy to use the onclick event, OH
Ah, this kind of mistake is hard to find, wrong do not know how wrong:
Here we should deal with the commit event in Submit_click, the first is to collect the information, here we see the
A Long-lost Request object and form method. This is almost identical with the ASP, I do not want to say more.
The next step is to write the collected data to the database, on the opening and execution of the database, as we said in the previous section
Out. There's no nagging here. Note that the correctness of the SQL statement is OK.
You should also pay attention to my join statement (because many people ask me how to link the MDB database, in fact, and ASP is
, the most important is that some people do not want to do their own practice, asking people has become a habit.
public string myconnstring= "Driver={microsoft Access Driver (*.mdb)};
Dbq=c:/test/test.mdb; ";
This is the most useful statement of access (personally), but there are many ways to do it. Like what:
Oh, originally this section is to speak DataSet, did not think of other text suddenly wrote so much, had to stay to
We'll talk about the dataset in the next section.
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.