刚刚写了一个C#数据库链接的程序  用到了一些系统类SqlConnection等  SqlConnection、SqlCommand、 SqlDataReader等是一些类 里面有各种方法 但是这些东西只在书上的例子中见过 不详细不全面  比如我想知道SqlDataReader这里面的都有什么方法 各是什么作用 以便我以后实用  这些东西MSDN里有吗 我查了下 结果如下:
 C# 
public class SqlDataReader : DbDataReader, IDataReader, IDisposable, IDataRecord
 
 示例代码:
C#  复制代码 
private static void ReadOrderData(string connectionString)
{
    string queryString =
        "SELECT OrderID, CustomerID FROM dbo.Orders;";    using (SqlConnection connection =
               new SqlConnection(connectionString))
    {
        SqlCommand command =
            new SqlCommand(queryString, connection);
        connection.Open();        SqlDataReader reader = command.ExecuteReader();        // Call Read before accessing data.
        while (reader.Read())
        {
            Console.WriteLine(String.Format("{0}, {1}",
                reader[0], reader[1]));
        }        // Call Close when done reading.
        reader.Close();
    }
}这些东西有用吗?貌似没提到关于SqlDataReader这个类中的方法和各种成员和属性吧  我该怎么办?

解决方案 »

  1.   

    有用
    都有讲解,很细致,各个参数的含义,返回值,实例代码都很详细,你想看书面讲解也有.
    建议如果刚开始也可以在www.asp.net中的startkit先学习学习,还有先看几本普通asp.net书,侧重与与数据库交互方面.
      

  2.   

    SqlDataReader中有 ExecuteReader()方法和GetString() 这些是我看书上的例子和请教别人知道的  可是具体的详细的技术文档哪里去查? 
      

  3.   

    google: 你要查的关键字    MSDN
    总能查出来
    你也可以查查cnblogs
      

  4.   

    这个是权威,绝对的有用
    ?貌似没提到关于SqlDataReader这个类中的方法和各种成员和属性吧  我该怎么办? 
    先选择索引,然后输入SqlDataReader然后你看SqlDataReader 类下面有一个"所有成员"然后你点击右边.......哇全出来来勒:D
      

  5.   

    http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx
    很详细了,左侧的目录树上分别有
    SqlDataReader Members
    SqlDataReader Methods
    SqlDataReader properties
      

  6.   

    SqlDataReader Methods 方法
    SqlDataReader properties属性楼主看不到么???
      

  7.   

    SqlDataReader Methods
       Name Description 
     Close Closes the SqlDataReader object. (Overrides DbDataReader..::.Close()()().) 
     CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) 
     Dispose Overloaded.  
     Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.) 
     Finalize Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) 
     GetBoolean Gets the value of the specified column as a Boolean. (Overrides DbDataReader..::.GetBoolean(Int32).) 
     GetByte Gets the value of the specified column as a byte. (Overrides DbDataReader..::.GetByte(Int32).) 
     GetBytes Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. (Overrides DbDataReader..::.GetBytes(Int32, Int64, array<Byte>[]()[], Int32, Int32).) 
     GetChar Gets the value of the specified column as a single character. (Overrides DbDataReader..::.GetChar(Int32).) 
     GetChars Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. (Overrides DbDataReader..::.GetChars(Int32, Int64, array<Char>[]()[], Int32, Int32).) 
     GetData Overloaded.  
     GetDataTypeName Gets a string representing the data type of the specified column. (Overrides DbDataReader..::.GetDataTypeName(Int32).) 
     GetDateTime Gets the value of the specified column as a DateTime object. (Overrides DbDataReader..::.GetDateTime(Int32).) 
     GetDateTimeOffset Retrieves the value of the specified column as a DateTimeOffset object. 
     GetDbDataReader Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation. (Inherited from DbDataReader.) 
     GetDecimal Gets the value of the specified column as a Decimal object. (Overrides DbDataReader..::.GetDecimal(Int32).) 
     GetDouble Gets the value of the specified column as a double-precision floating point number. (Overrides DbDataReader..::.GetDouble(Int32).) 
     GetEnumerator Returns an IEnumerator that iterates through the SqlDataReader. (Overrides DbDataReader..::.GetEnumerator()()().) 
     GetFieldType Gets the Type that is the data type of the object. (Overrides DbDataReader..::.GetFieldType(Int32).) 
     GetFloat Gets the value of the specified column as a single-precision floating point number. (Overrides DbDataReader..::.GetFloat(Int32).) 
     GetGuid Gets the value of the specified column as a globally unique identifier (GUID). (Overrides DbDataReader..::.GetGuid(Int32).) 
     GetHashCode Serves as a hash function for a particular type. (Inherited from Object.) 
     GetInt16 Gets the value of the specified column as a 16-bit signed integer. (Overrides DbDataReader..::.GetInt16(Int32).) 
     GetInt32 Gets the value of the specified column as a 32-bit signed integer. (Overrides DbDataReader..::.GetInt32(Int32).) 
     GetInt64 Gets the value of the specified column as a 64-bit signed integer. (Overrides DbDataReader..::.GetInt64(Int32).) 
     GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) 
     GetName Gets the name of the specified column. (Overrides DbDataReader..::.GetName(Int32).) 
     GetOrdinal Gets the column ordinal, given the name of the column. (Overrides DbDataReader..::.GetOrdinal(String).) 
     GetProviderSpecificFieldType Gets an Object that is a representation of the underlying provider-specific field type. (Overrides DbDataReader..::.GetProviderSpecificFieldType(Int32).) 
     GetProviderSpecificValue Gets an Object that is a representation of the underlying provider specific value. (Overrides DbDataReader..::.GetProviderSpecificValue(Int32).) 
     GetProviderSpecificValues Gets an array of objects that are a representation of the underlying provider specific values. (Overrides DbDataReader..::.GetProviderSpecificValues(array<Object>[]()[]).) 
     GetSchemaTable Returns a DataTable that describes the column metadata of the SqlDataReader. (Overrides DbDataReader..::.GetSchemaTable()()().) 
     GetSqlBinary Gets the value of the specified column as a SqlBinary. 
     GetSqlBoolean Gets the value of the specified column as a SqlBoolean. 
     GetSqlByte Gets the value of the specified column as a SqlByte. 
     GetSqlBytes Gets the value of the specified column as SqlBytes. 
     GetSqlChars Gets the value of the specified column as SqlChars. 
     GetSqlDateTime Gets the value of the specified column as a SqlDateTime. 
     GetSqlDecimal Gets the value of the specified column as a SqlDecimal. 
     GetSqlDouble Gets the value of the specified column as a SqlDouble. 
     GetSqlGuid Gets the value of the specified column as a SqlGuid. 
     GetSqlInt16 Gets the value of the specified column as a SqlInt16. 
     GetSqlInt32 Gets the value of the specified column as a SqlInt32. 
     GetSqlInt64 Gets the value of the specified column as a SqlInt64. 
     GetSqlMoney Gets the value of the specified column as a SqlMoney. 
     GetSqlSingle Gets the value of the specified column as a SqlSingle. 
     GetSqlString Gets the value of the specified column as a SqlString. 
     GetSqlValue Returns the data value in the specified column as a SQL Server type.  
     GetSqlValues Fills an array of Object that contains the values for all the columns in the record, expressed as SQL Server types. 
     GetSqlXml Gets the value of the specified column as an XML value. 
     GetString Gets the value of the specified column as a string. (Overrides DbDataReader..::.GetString(Int32).) 
     GetTimeSpan Retrieves the value of the specified column as a TimeSpan object. 
     GetType Gets the Type of the current instance. (Inherited from Object.) 
     GetValue Gets the value of the specified column in its native format. (Overrides DbDataReader..::.GetValue(Int32).) 
     GetValues Gets all attribute columns in the collection for the current row. (Overrides DbDataReader..::.GetValues(array<Object>[]()[]).) 
     InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) 
     IsCommandBehavior Determines whether the specified CommandBehavior matches that of the SqlDataReader . 
     IsDBNull Gets a value that indicates whether the column contains non-existent or missing values. (Overrides DbDataReader..::.IsDBNull(Int32).) 
     MemberwiseClone Overloaded.  
     NextResult Advances the data reader to the next result, when reading the results of batch Transact-SQL statements. (Overrides DbDataReader..::.NextResult()()().) 
     Read Advances the SqlDataReader to the next record. (Overrides DbDataReader..::.Read()()().) 
     ToString Returns a String that represents the current Object. (Inherited from Object.) 
    方法N多啊,一个个都有对应链接
      

  8.   

    MSDN适合当你有一些眉目,但是不清楚具体调用的时候有很大作用,如果把MSDN当教程来翻,会看晕的,因为里面的脉络太复杂了,很难理清晰。
      

  9.   

    /建军立连接字符串
    string connectionString="Data Source=zxm-d364b9d4f52;
    Initial Catalog=sql1;Integrated Security=True;Pooling=False";
    //建立连接
    SqlConnection mySqlConnection=new SqlConnection(connectionString);
    //打开连接
    mySqlConnection.Open();
    //新建Sql命令
    SqlCommand myCommand=mySqlConnection.CreateCommand();
    myCommand.CommandText="select * from T_student";
    //从数据库获取数据
    SqlDataReader myDataReader=myCommand.ExecuteReader();
    //读取myDataReader数据集中的数据
    while(myDataReader.Reader())
    {
    Console.WriteLine("{0}  {1}  {2}",myDataReader["id"],
    myDataReader["name"],myDataReader["password"]);
    }
    //关闭myDataReader
    myDataReader.Close();
    //关闭数据库连接
    mySqlConnection.Close();
      

  10.   

    /建军立连接字符串
    string connectionString="Data Source=zxm-d364b9d4f52;
    Initial Catalog=sql1;Integrated Security=True;Pooling=False";
    //建立连接
    SqlConnection mySqlConnection=new SqlConnection(connectionString);
    //打开连接
    mySqlConnection.Open();
    //新建Sql命令
    SqlCommand myCommand=mySqlConnection.CreateCommand();
    myCommand.CommandText="select * from T_student";
    //从数据库获取数据
    SqlDataReader myDataReader=myCommand.ExecuteReader();
    //读取myDataReader数据集中的数据
    while(myDataReader.Reader())
    {
    Console.WriteLine("{0}  {1}  {2}",myDataReader["id"],
    myDataReader["name"],myDataReader["password"]);
    }
    //关闭myDataReader
    myDataReader.Close();
    //关闭数据库连接
    mySqlConnection.Close();