SqlDataReader : SqlDataReader « ADO.Net « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » ADO.Net » SqlDataReader 
32.26.1.SqlDataReader
using System;
using System.Data;
using System.Data.SqlClient;

class MainClass
{
  [STAThread]
  static void Main(string[] args)
  {
    string ConnectionString ="server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI;";
    string SQL = "SELECT * FROM Employee";

    SqlConnection conn = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand(SQL, conn);
        
    conn.Open();
    SqlDataReader reader = cmd.ExecuteReader();
    Console.WriteLine("ID, FirstName");

    while (reader.Read())
    {
      Console.Write(reader["ID"].ToString() ", ");
      Console.Write(reader["FirstName"].ToString() ", ");
    }
    reader.Close();
    conn.Close();
  }
}
32.26.SqlDataReader
32.26.1.SqlDataReader
32.26.2.Use SQL Server Data Provider
32.26.3.Reference result set by column name in SqlDataReader
32.26.4.Reference result set by column index in SqlDataReader
32.26.5.Ordinal Indexer demo
32.26.6.Use loop to read all data in SqlDataReader
32.26.7.Use SqlDataReader to retrieve data in the resultset
32.26.8.Get data by data type using SqlDataReader
32.26.9.Using a DataReader to read row by row
32.26.10.Updating Data Using CommondBuilder
32.26.11.SqlDataReader: RecordsAffected
32.26.12.Typed Accessors: int, varchar and decimal
32.26.13.SqlDataReader.GetString, GetDateTime
32.26.14.how to read a table schema
32.26.15.Use indexer to read data
32.26.16.Mapping .NET Data Provider Data Types to .NET Framework Data Types by calling the GetXXX method
32.26.17.Mapping .NET Data Provider Data Types to .NET Framework Data Types by casting
32.26.18.Mapping .NET Data Provider Data Types to .NET Framework Data Types by converting
32.26.19.Retrieving a Result Set Stream Using a DataReader
32.26.20.Retrieves data as native SQL Server types.
32.26.21.Schema Table from SqlDataReader
32.26.22.ResultSet Info
32.26.23.Output fields from DataReader row
32.26.24.Ordinal Indexer
32.26.25.Get the column ordinal for the Phone attribute and use it to output the column
32.26.26.Data Reading with SqlDataReader
32.26.27.Accessing Data Values in a DataReader
32.26.28.DataReader has records using HasRows property
32.26.29.Handle Multiple Results
32.26.30.Determining the Number of Records Returned in a DataReader
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.