In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to achieve multiple result sets in ADO.NET NextResult". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
ADO.NET provides consistent access to data sources such as SQL Server and XML, as well as data sources exposed through OLE DB and ODBC. User applications that share data can use ADO.NET to connect to these data sources and retrieve, process, and update the data they contain.
Through data processing, ADO.NET decomposes data access into multiple discontiguous components that can be used separately or used before and after. ADO.NET contains .NET Framework data providers for connecting to databases, executing commands, and retrieving results. These results are either processed directly, placed in ADO.NET DataSet objects to be exposed to users in a special way, and combined with data from multiple sources, or passed between tiers. DataSet objects can also be used to manage data local to the application or data derived from XML, independent of the .NET Framework data provider. The ADO.NET class is located in System.Data.dll and integrates with the XML class in System.Xml.dll.
ADO.NET provides developers who write managed code with functionality similar to that provided by ActiveX data objects (ADO) to native component object model (COM) developers. It is recommended that you use ADO.NET instead of ADO to access data in .NET applications. If multiple result sets are returned, DataReader provides a NextResult method to iterate through the result sets sequentially. The following example shows how SqlDataReader uses the ExecuteReader method to process the results of two SELECT statements.
ADO.NET NextResult retrieves multiple result sets VisualBasic
PrivateSubRetrieveMultipleResults (ByValconnectionAsSqlConnection) Usingconnection DimcommandAsSqlCommand=NewSqlCommand (_ "SELECTCategoryID,CategoryNameFROMCategories;" & _ "SELECTEmployeeID,LastNameFROMEmployees", connection) connection.Open () DimreaderAsSqlDataReader=command.ExecuteReader () DoWhilereader.HasRows Console.WriteLine (vbTab&reader.GetName (0) _ & vbTab&reader.GetName (1) DoWhilereader.Read () Console.WriteLine (vbTab&reader.GetInt32 (0) _ & vbTab&reader.GetString (1)) Loop reader.NextResult () Loop EndUsing EndSub
ADO.NET NextResult retrieves multiple result sets C #
StaticvoidRetrieveMultipleResults (SqlConnectionconnection) {using (connection) {SqlCommandcommand=newSqlCommand ("SELECTCategoryID,CategoryNameFROMdbo.Categories;" + "SELECTEmployeeID,LastNameFROMdbo.Employees", connection); connection.Open (); SqlDataReaderreader=command.ExecuteReader (); while (reader.HasRows) {Console.WriteLine ("\ t {0}\ t {1}", reader.GetName (0), reader.GetName (1)) While (reader.Read ()) {Console.WriteLine ("\ t {0}\ t {1}", reader.GetInt32 (0), reader.GetString (1));} reader.NextResult ();} "ADO.NET NextResult search how to implement multiple result sets" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.