Csharp/CSharp Tutorial/ADO.Net/IDataReader — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:19, 26 мая 2010
Get data from IDataReader
<source lang="csharp">using System; using System.Data; using System.Data.SqlClient; class MainClass {
public static void Main() { using (SqlConnection con = new SqlConnection()) { con.ConnectionString = @"Data Source = .\sqlexpress;" + "Database = Northwind; Integrated Security=SSPI"; con.Open(); // Create and configure a new command. IDbCommand com = con.CreateCommand(); com.rumandType = CommandType.StoredProcedure; com.rumandText = "MyStoredProcedure"; // Execute the command and process the results using (IDataReader reader = com.ExecuteReader()) { while (reader.Read()) { Console.WriteLine(" {0} ", reader["FirstName"]); } } } }
}</source>