I have learned something, there is a mess, economics, marketing, English, computer style, but no proficiency. Friends often advise me to find the same hand. But there is always no need. I think I may not be suitable for professional people. In fact, learning is for me, more like a interest, there is no purpose, learning, don't ask other. Just like someone likes games, some people like Chat. Microsoft's .NET has been a long time. I have learned a few more time. I have seen a lot of books. I always have three different five, I don't know what I have learned, what will I do? Think about it or have a summary, first start with ADO.NET.
The SDK can be seen, ADO.NET is introduced from system.data.ado (I used NetBeta1 version here, it seems that I have changed into systm.data.oledb in beta2, these things are not important, you can check it, The key is to think about ADO in ASP3.0, in ADO.NET, the application programming interface (API) provided by Managed Provider, can easily access data of various data sources, including OLEDB support And ODBC supported databases.
Find a lot of information in SDK (see Figure 1), what do you eNGLISH is not good? That's a trouble, I will tell you that you have to say that English is a tool. What does it feel more? No, you have to eat some bitterness. If China has joined the WTO in November this year, it will be more understandable. In fact, I don't understand those things, teach you a trick. In the first two months, I saw a book, .NET framework, a total of four books. But I only have seen two, one is the system class, one is the database class. It can be said that Microsoft SDK's original translation, you can borrow, after a book, things have been learned, English is not a problem (at least in the .NET class vocabulary). Do you feel that my article benefits?
(Figure 1)
In the help of ADO.NET, you can see something such as Class, Delegates, such as AdoCommand, Adoconnection, AdoDataSetCommand, etc. (note that these have changed in beta2, I said that mainly thinking, changing things It's just a few letters, just like if I want to use SQL Server, I just change the ADO to SQL, a truth) I will say slowly. Here, I am going to write anything else than anyone else to or anywhere, most of the country is to complete the SDK. But if you look at every nonsense I wrote, you may give you the time of walking. At least I think it is like this.
Not the beginning of the beginning
Some stories have not started, I haven't started something, for this part, I mentioned two important concepts, Managed Provider and DataSet.
I said that Managed Provider is a reference for the application interface. Data of various data sources can be easily accessed by the App Programming Interface (API) provided by Managed Provider.
(Figure II)
The basic structure of data access is visible as shown in the figure above (from Microsoft SDK). In the past, when we use the ASP, the data access by ADO is based on the connection programming model. The connection is disconnected, and the data cannot be renewed. In ADO.NET, DatSetCommand plays an extremely important role. It can retrieve a DataSet and maintain a "bridge" between data and DataSet to facilitate access and modification of data. DataSetCommand automatically transforms the various operations of the data to the appropriate SQL statement related to the data source. Four command objects: SelectCommand, INSERTCOMMAND, UPDATECMMAVAND, DELETECMMAND instead of database query, insert, update, delete operation. And this is disconnected. While learning Microsoft.Net, you can imagine DataSet as a relational database such as the database built by Access. The difference is that it is built in memory. Some people disagree with this statement, but I can't see anything, I just think so, how do you think you look at it? Play by your owppy. (As you can do your own principles, so you will live very happy. This is the sentence pattern I recorded in English yesterday, to Play by One's Own Rules A person's own principles. Lai Shi Xiong teacher edited, very good! I have time to buy a book, package you value, my English is not good, but that is a skilled process, every day, I don't know China naturally became a master), you see what something is a truth, perseverance, no unsuccessful. We continue to say DataSet, which supports multi-table, intervals, data constraints, etc., these and relational databases are generally no. For example, I created a DataSet: Sample, and compares with a Sample.mdb established with Access. After connecting the connection object connection, the command object command is connected to sample.mdb, and a DataSet object Sample is created in memory. In Sample establish and sample. MDB, such as Customer (Customer Table), Urine (Urinary Checklist), etc.
Then, the DataSet object Sample in memory is almost the same as Sample.mdb.
Access created database Sample.mdb
DataSet object Sample in memory
Customer
Customer
Urine
Urine
Gorgeous
Gorgeous
The table in the DataSet is represented by DataTable. DataSet can contain a lot of DataTable, which constitutes a table collection TableScollection object. These can be found in SDK's System.Data:
(Figure 3)
There is very detailed there, if English is not very good, you can take the method mentioned earlier, one fell again.
Not a text of the text: database connection
Let us recall the connection between the ASP database, (you may see that when I am writing something, I will mention some courses that may have not learned, this is not important. If you have learned, you will understand the fast. If you have not learned, do not affect your study.) Generally completed three steps:
Connect the water pipe to the faucet, namely Ado.connection; open the faucet according to the designated requirements, and execute SQL, generate the RECORDSET. Use the water you master to use. That is, check, increase, delete, and change the database. Sometimes I will want to add this step of closing the data link, but still get it. Because I found some universities in our country, or some living areas, I often don't know how to cherish it. Some public faucets, after using it, never gone. So I want to close the faucet this step. I still don't say it. Said that you can't remember until you find your own procedures and others, but slowly, it will remember more clearly than anyone. I have to go to Peking University to eat, see a classmate, put the remaining half plate directly into the water ditch, and it is easy to block the sewer, but it is not a matter. Until I use my hand, I'm full of red, why can't I pay attention to some? There is also a few days ago, I said that a mayor of Northeast China was rushing up from the plane. At that time, I was really a word for the Chinese. Book is positive, in ADO.NET, there are a few points to change:
First, the database link can be disconnected, and the variations made are operations in DataSet. Second, the introduced DataSet is in the interior of the XML standard, which means that it is independent of the platform and language. Third, when references ADO.NET, use domain name space (Namespace). Not an object reference.
Therefore, the corresponding relationship will become: 1. Reference Domain Name Space 2, create a database link (which is on the water dragon head is connected to the water pipe) 3, request a record collection (which is the object of the remaining water) 4, The resulting record set temporarily present within the specified DataSet. (You put the water in the basin, and the basin is in a room. So when you take water, you can specify the use of red basin in the Jiang Zhihui room. 5, turn off the database link ( That is to close the faucet) 6, doing the required operations on the DataSet.
Compared to the above steps, I tell the form of decomposition, don't see decomposition, you are very lucky, I have this master to refer to you, say less than half a year. (I rely on, you throw me, a few people, come out and then pick up)
Reference domain name space I think this technology may be from Java, of course, I also heard that in order to verify, a part of Java and JSP books are almost. In fact, many Microsoft's stuff is learning others. As a result, I like it this way. Unlike many domestic programmers, Microsoft's things are made in imitation, and a pair is not good, it seems that he is high, you also look at it! The four major inventions are invented by the Chinese, but unfortunately, it is in the west. Many Chinese inventions are printed by people in the words of Made in America. wake up! Chinese people! The foot-on-earth man is learning some people in life, it is a good thing. OK, far, domain name space I have difficulty giving it a definition, not writing, always don't care. You will see the example of the red water basin I have just given you, I think it. Maybe you can also think so if you are in Peking University, of course, if you like Tsinghua, you can. When you are looking for him, I found Peking University, and then the Guanghua School of Management, and then the 217 room, then Yang Qirong. This is the domain name space. Microsoft is recorded in this way. Peking University. Guanghua School of Management .217. Yang Qirong. That. Probably it means, if you use Microsoft programming tools to understand. Then quote, just like this <% @ import namespace = "Peking University. Guanghua Management College. 217. Yang Qirong"% ". Of course, you can also introduce Liu Dehua, Guan Zhilin (Lin is not a mistake). Then in ADO.NET, it should be like this: <% @ Import namespace = "system.data"%> <% @ import name "%> If you are using SQL Server, you can Use: <% @ Import namespace = "system.data"%> <% @ import namespace = "system.data.sql"%> In fact, these have changed in the beta2 version, but don't matter, don't go through I sincerely, if there is no special case in the future, I will no longer explain it. Everyone may notice that when using SQL Server, the namespace references are different. The use of System.Data.sql, which can also access SQL Server using System.Data.ado. Just use system.data.sql more efficient, why? Because Microsoft has made it out of it. Otherwise, there can only be two fools now, one is me, one is Microsoft. So, don't consider why, just use system.data.sql when using SQL Server, because Microsoft is not a fool, I don't know. But I am absolutely not FOOL.
Create a database link (which is on the water tube on the water tap) below is a C # program, create a function, is an example of Access: public void createadoconnection () {adoconnection myconnection = new adoconnection (); myconnection.connectionstring = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = NWIND_RW.MDB "; myConnection.ConnectionTimeout = 30; myConnection.Open (); myConnection.IsolationLevel = IsolationLevel.ReadCommitted;} this example shows how to connect to the ms sql server pubs database: string strconnstring; strconnstring = "provider =" sqloledb; data source = (local); "&" initial catalog = pubs; user id = sa "; adoconnection objconn; objconn = new adoconnection; objconn.connectionstring = strconnstring; Objconn.open (); saw it, it is very simple, no big deal (no big deal, like a certain advertisement)
Basic ideas are as follows, set a corresponding string you want to join the database, you can check it in the control panel, or get directly in the SDK. The second step sets an adoconnection object, assigns the string to it, and opens it with the Open method. This is a set of routines. Understand the line, replicate in the SDK when used, and change the corresponding characters. Or Mr. Wang Guorong's method, simply do a function, reference to it.
Request a record collection (that is, the object to find the remaining water) is an example, // Create a SQL string string strsql = "select * from Jiang Zhihui"; // Create an object adodatasetcommand and datasetadodatasetcommand objcommand; dataset objDataSet = new dataset; Objcommand = New AdodatasetCommand (strsql, objconn); // Plug data to DataSet // and name the data collection "Objcommand.FillDataSet (ObjdataSet," 详 详 详 ");
Explain, here is the use of AdoDataSetCommand through the SQL command in the strsql string and the join mentioned in front of the Objconn, create a DataSet record set (please become a data sheet) "靓 详 details", and it is a DataSet object The image of the ObjDataSet is like a data representation. Microsoft while you directly to a function available in sdk: public DataSet SelectAccessRows (DataSet myDataSet, string myConnection, string mySelectQuery, string myTableName) {ADOConnection myAccessConn = new ADOConnection (myConnection); ADODataSetCommand myAccessDataSetCmd = new ADODataSetCommand (); myAccessDataSetCmd.SelectCommand = new ADOCommand (mySelectQuery, myConnection); // fill myDataSet with data from myTableNamemyAccessDataSetCmd.FillDataSet (myDataSet, myTableName); return myDataSet;} vb unfortunately did not do, and it's okay, I'll be in you comes after a number of semi-finished products of this series of articles Function, beneficial to your programming. You just have to modify it. Turn off the database link This is very simple, objconn.close (); // Turns the data link objconn = Nothing; // Eliminate the object over!
In the DataSet, this is the key section of programming. I decided to be a text, first give a small example to see: myfirstdatagrid.datasource = objDataSet.Tables ("详 details") .defaultView; myfirstdataGrid. Database (); complete! Give me!
A small example: Test1.aspx (I am packaged in the Samples folder) This example uses a data as a file Test.mdb, a config.web file, a test1.aspx. The source code for the TEST1.ASPX file is as follows: <% @ page language = "c #"%>