In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use ADO.NET to read data, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
ADO.NET is still quite commonly used, so I studied the ADO.NET read data, here to share with you, I hope to be useful to you. One way is to connect directly to the database, even if you use Command objects to access the database. In this way, the data is read through the DataReader object ADO.NET, and then displayed using Response.Write. The advantage of this approach is that it does not take up extra memory, but reads data faster, but requires a long amount of program code.
Another way is to cache the data in DataSet, even if you use DataAdapter objects to access the database. In this way, the data is displayed directly by using the DataSet object with the interface provided by the DataGrid object. The advantage of this approach is that it requires less code, but takes up extra memory, and ADO.NET reads data more slowly than the previous approach.
Examples are as follows:
Private void BindData () {SqlConnection myConnection=conn (); string queryStr= "select RecordNO,SendTime,Creater,CustomerID,SMSInfor from SendBoxInformation order by RecordNO DESC"; SqlDataAdapter myDataAdapter=new SqlDataAdapter (queryStr,myConnection); DataSet myDataSet=new DataSet (); myDataAdapter.Fill (myDataSet, "SendBox"); if (myDataSet.Tables ["SendBoxInformation"] .Rows.Count > 0) {DataGrid1.DataSource=myDataSet.Tables ["SendBox"] .DefaultView; DataGrid1.DataBind ();} else {DataGrid1.Visible=false;}}
This is a custom data access function: the second way to access the database using ADO.NET: Connection-> DataAdapter-> DataSet-> DataGrid workflow: specify the data source, connect to Microsoft SQL Server version 7.0 or later, and use the SqlConnection object of the SQL Server .NET Framework data provider. Write relevant SQL statements to create DataAdapter objects that access the data table. Use the DataSet object to hold the data table and populate it into the DataAdapter object. Use the DataGrid control to bind data and display the data table.
Prospect
The conceptual model is abstracted from the complicated relational data model. In this way, developers can only focus on the conceptual model, instead of caring about the complicated relational data model, so as to improve the development efficiency. So how can this be done? The answer is: Language-Integrated Query and ADO.NET Entity Framework, the next generation of ADO.NET Entity Framework, include
1. Entity data model (Entity Data Model), developers abstract a very appropriate model through EDM.
two。 Very powerful client-view/mappping engine for mapping data relationships
3. Full support for EDM schemas in Entity SQL language and LINQ query
4. Ojbect services layer allows you to choose how to process query results. For example, (rows, columns, or as objects).
5. Provides an open model so that ADO.NET Entity Framework can handle other data stores.
The above is all the contents of the article "how to use ADO.NET to read data". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.