Asynchronous Specific Command Object Methods in Visual Studio .NET

Encoding QR Code 2d barcode in Visual Studio .NET Asynchronous Specific Command Object Methods

Asynchronous Specific Command Object Methods
Print QR Code In VS .NET
Using Barcode printer for ASP.NET Control to generate, create QR-Code image in ASP.NET applications.
www.OnBarcode.com
Generating Bar Code In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create barcode image in ASP.NET applications.
www.OnBarcode.com
Method BeginExecuteNonQuery
Quick Response Code Generation In Visual C#
Using Barcode generator for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
QR Code ISO/IEC18004 Creation In .NET Framework
Using Barcode generator for .NET framework Control to generate, create Denso QR Bar Code image in Visual Studio .NET applications.
www.OnBarcode.com
Description Starts the asynchronous version of the ExecuteNonQuery method.
Quick Response Code Generation In VB.NET
Using Barcode creator for Visual Studio .NET Control to generate, create QR Code image in .NET framework applications.
www.OnBarcode.com
Paint Bar Code In VS .NET
Using Barcode printer for ASP.NET Control to generate, create bar code image in ASP.NET applications.
www.OnBarcode.com
6
UPC-A Generator In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create UCC - 12 image in ASP.NET applications.
www.OnBarcode.com
Making UCC-128 In VS .NET
Using Barcode maker for ASP.NET Control to generate, create USS-128 image in ASP.NET applications.
www.OnBarcode.com
Working with Data in a Connected Environment
Paint EAN / UCC - 13 In .NET
Using Barcode encoder for ASP.NET Control to generate, create EAN-13 Supplement 5 image in ASP.NET applications.
www.OnBarcode.com
Print PDF417 In .NET Framework
Using Barcode generation for ASP.NET Control to generate, create PDF417 image in ASP.NET applications.
www.OnBarcode.com
Table 6-6
QR Code Generation In .NET Framework
Using Barcode generation for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
www.OnBarcode.com
Code 11 Drawer In VS .NET
Using Barcode creation for ASP.NET Control to generate, create USD8 image in ASP.NET applications.
www.OnBarcode.com
Asynchronous Specific Command Object Methods
PDF417 Drawer In Java
Using Barcode printer for Android Control to generate, create PDF417 image in Android applications.
www.OnBarcode.com
Draw PDF-417 2d Barcode In Java
Using Barcode maker for Java Control to generate, create PDF 417 image in Java applications.
www.OnBarcode.com
Method BeginExecuteReader BeginExecuteXmlReader EndExecuteNonQuery EndExecuteReader
Encode Barcode In VS .NET
Using Barcode encoder for .NET Control to generate, create barcode image in .NET applications.
www.OnBarcode.com
Draw PDF417 In None
Using Barcode maker for Office Word Control to generate, create PDF417 image in Office Word applications.
www.OnBarcode.com
Description Starts the asynchronous version of the ExecuteReader method. Starts the asynchronous version of the ExecuteXmlReader method. Call this method after the StatementComplete event fires to complete execution of the command. Call this method after the StatementComplete event fires to return the DataReader with the data returned by the command. Call this method after the StatementComplete event fires to return the XmlReader with the data returned by the command.
Reading QR Code In C#
Using Barcode decoder for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Recognize Bar Code In Visual C#.NET
Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in .NET framework applications.
www.OnBarcode.com
EndExecuteXMLReader
EAN-13 Supplement 5 Maker In Visual Studio .NET
Using Barcode creator for Reporting Service Control to generate, create UPC - 13 image in Reporting Service applications.
www.OnBarcode.com
Creating Barcode In Java
Using Barcode creation for Java Control to generate, create bar code image in Java applications.
www.OnBarcode.com
When executing commands asynchronously, you explicitly call the Begin and End methods of the selected Command object. Calling the Begin method sends the com mand (SQL statement or stored procedure call) to the database, and then you can per form other operations in your application. When the command finishes executing, the StatementCompleted event fires, notifying the application that it can call the End method of the command and access the data for further processing. The following code shows how you can continue processing even while a command is in the process of executing:
'VB Dim results As New System.Text.StringBuilder Dim NorthWindConnection As New SqlConnection("Data Source=.\;Initial Catalog=Northwind;" & _ Integrated Security=True; asynchronous processing = true") Dim command1 As New SqlCommand("WAITFOR DELAY '00:00:05'; " & _ Select * From [Order Details]", NorthWindConnection) NorthWindConnection.Open()
Dim r As IAsyncResult = command1.BeginExecuteReader
MessageBox.Show("The command has been executed but processing is free to display" & _ " this message before the results have been returned!") Dim reader As SqlDataReader = command1.EndExecuteReader(r)
Lesson 1: Creating and Executing Command Objects
While reader.Read For i As Integer = 0 To reader.FieldCount - 1 results.Append(reader(i).ToString & vbTab) Next results.Append(Environment.NewLine) End While reader.Close() command1.Connection.Close() MessageBox.Show(results.ToString) // C# System.Text.StringBuilder results = new System.Text.StringBuilder(); SqlConnection NorthWindConnection = new SqlConnection("Data Source=.\\;Initial Catalog=Northwind;" + "Integrated Security=True; asynchronous processing = true"); SqlCommand command1 = new SqlCommand("WAITFOR DELAY '00:00:05'; " + Select * From [Order Details]", NorthWindConnection); NorthWindConnection.Open(); IAsyncResult r = command1.BeginExecuteReader(); MessageBox.Show("The command has been executed but processing is free " + "to display this message before the results have been returned!"); SqlDataReader reader = command1.EndExecuteReader(r);
while (reader.Read())
for (int i = 0; i< reader.FieldCount - 1; i++) { results.Append(reader[i].ToString() + "\t"); } results.Append(Environment.NewLine); } reader.Close(); command1.Connection.Close(); MessageBox.Show(results.ToString());
Executing Multiple SQL Statements Using a DataReader
In addition to returning the results from a single SQL statement, you can use a Command object and DataReader to return the results of multiple SQL statements. To execute more than one SQL statement, set the CommandText property of a Command object to multiple SQL statements separated by semicolons (;). After calling the ExecuteReader method, the DataReader will hold the number of result sets equal to the number of SQL statements executed. To access the data returned by the additional statements, call the NextResult method of the DataReader.
6
Working with Data in a Connected Environment
For example, the following code creates a SqlCommand and sets it to call two separate SQL statements that return data from different tables. To access the additional data, check the value of the DataReader.NextResult method. If it returns True, there is another result set in the reader; if it returns False, the reader is done.
NOTE
Updating a Previous Exercise
You can modify the code in the ExecuteSqlButton event handler with the following example to try out returning multiple result sets.
' VB ExecuteSqlCommand.CommandText = "SELECT CustomerID, CompanyName" _ & "FROM Customers; SELECT ProductName, UnitsInStock FROM Products" Dim reader As SqlDataReader = ExecuteSqlCommand.ExecuteReader Dim MoreResults As Boolean = True Do While MoreResults While reader.Read For i As Integer = 0 To reader.FieldCount - 1 results.Append(reader(i).ToString & vbTab)
Next
results.Append(Environment.NewLine)
End While MoreResults = reader.NextResult() Loop // C# ExecuteSqlCommand.CommandText = "SELECT CustomerID, CompanyName FROM " + "Customers; SELECT ProductName, UnitsInStock FROM Products"; SqlDataReader reader = ExecuteSqlCommand.ExecuteReader(); bool MoreResults = false; do { while (reader.Read()) { for (int i = 0; i < reader.FieldCount; i++)
results.Append(reader[i].ToString() + "\t"); } results.Append(Environment.NewLine); } MoreResults = reader.NextResult(); } while (MoreResults);
Copyright © OnBarcode.com . All rights reserved.