DataReader Visual C# ??? ????? ?? ?????? ???????? ?? ????? ???? ?? ?????????

???? ?????? ???? ??????
???? ID: 311274 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ??? ?? ??????? ??????? ?? ?? ????? ?? ???? ??? ???????? ?????? recordsets ?? ???? ??????? ?? ???? ????????? ???? ?? ??? ??????????? ?? ??? SQL ??? ?? ?????????

????? ?? ?????

???? ??????? ?????? ?? ActiveX ???? ?????????? (ADO) ??????? ?? ???? ??? ????? ?? ????:
  • ?????? ???
  • ?????? ?????? ?????? ??????? ???????? ?? ?????? (???????? ????, ??????, ?????, ?? ??? ??? ????)
  • ??????? ????? ?? ???????
  • ?????? ?????
  • ????? ??? ???????? ?????????, ?? ?????? ????????
???????? ?? ?? ??? SQL ??? ?????, ?? ?? ????? ?? ???? ??? ???NextResult????? ?? ??? ????DataReaderresultset ??? ???? ?????? ???

??????????

????? ???? ???????? ?????????, ?????????? outlines, ??????? ???? ??????, ?? ???? ???? ???:
  • Microsoft Windows 2000 Professional, Windows 2000 ?????, Windows 2000 ?????, ?? Windows NT 4.0 ????? ?????
  • Microsoft Visual Studio.???
  • Microsoft SQL Server 7.0 ?? ??? ?? ???????
?? ???? ????? ?? ?? ?? ?????????? ?? ??? ?????? ??? ????:
  • ????? ????????????
  • ADO.??? ????? ?? ????????

????????? ????? ?? ??? ??????

SQL ????? Pubs ?????? ?????? ????? ??? ?? ????? ???? ?? ????? ????????
  1. ?????????? ??? ?? SQL ?????? ???????? ??? ??????? ????? ?? ISQL ??????:
    CREATE PROC MyProc
    AS
        SELECT * FROM Authors
        SELECT * FROM Authors WHERE State = 'CA'
    GO 
    					
  2. ????? ???????? ?? ??????? ?????????
  3. ??? ??? Windows ????????? ????????? Visual C# ??? ?????????? Form1 ???????? ??? ?? ????????? ??? ????? ???
  4. ????????? ???? ?? ???? ????????? ?? ?????? ??System.Data??? ?????, ?? ?? ???? ?? ?? ?? ??? ????? ?? ??? ?? ?????? ?????? ?????
  5. ????? ???????Form1 ?? ???? ????????? ?????????? ??? ???? ??btnTest, ?? ????????? ??????????? ?? ??? ??????????.
  6. ?? ????? ?????? ????? ?????????????,System.Data.OleDb, ??System.Data.SqlClient???????? ???? ?? declarations ????? ???????? ???? ?? ??? ?? ???????? ???? ??? ??? ??? ???? ??????? ??? ?????????? ??? ?????? Form1 ?? declarations ??????:
    using System;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    					
  7. ???? ?? ??? ?????????? ??? ??????btnTest_Click????:

    ???<user name="">?????????? ID ????? ??? ?? ??? ??????? ????????? ???? ???? ?? ??? ???? ?? ???????. ?? ???????? ????</user>
        String myConnString  = "User ID=<username>;password=<strong password>;Initial Catalog=pubs;Data Source=myServer";
        SqlConnection myConnection = new SqlConnection(myConnString);
        SqlCommand myCommand = new SqlCommand();
        SqlDataReader myReader ;
    
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Connection = myConnection;
        myCommand.CommandText = "MyProc";
        int RecordCount=0; 
    
        try
        {
            myConnection.Open();
    	myReader = myCommand.ExecuteReader();
    
    	while (myReader.Read())
    	{
     	    //Write logic to process data for the first result.
    	    RecordCount = RecordCount + 1;
    	}
    	MessageBox.Show("Total number of Authors: " + RecordCount.ToString());
    
    	myReader.NextResult();
    	RecordCount = 0;
    
    	while (myReader.Read())
    	{
    	    //Write logic to process data for the second result.
    	    RecordCount = RecordCount + 1;
    	}
    	MessageBox.Show("Authors from California: " + RecordCount.ToString());
        }
        catch(Exception ex) 
        {
           MessageBox.Show(ex.ToString());
        }
        finally
        {
    	myConnection.Close();
        }
    					
  8. ??????? ???????? (??????? ????myConnString) ?? ??? ??? ???? ??????? ?? ??? ????????
  9. ???? ????????? ?? ??????? ?????? ???????? ??, ????? ??????????? ???????? ????????? ?? ????? ?? ????
  10. ????? ???????????. ????? ????? ???? ????????? ????? ?? ???????? ????????? ???? ???

??????

?? ??? ???????? ????????? ??? ?? ???? ??? ???????? ??????? ????? ???? ???? Microsoft ???????? ??? ???? ????? ?? ??? ????? ??????:
306574ASP ??? ???????? ????????? SQL ????? ?? ??? ???? ?? ??? ????????
???????? ??????? ?? ??? ?????? ???????? ?? ???? ??? ??? ??? ????? ?? ??? ????? ???? ?????? ?? ????? ???? Microsoft ????????:
308650ADO ?? ????? ???? ?????????? ??????? ????????? ??????? ???? ?? ??? ???????? ??? Visual C#.???
???????? ?? ???? ??? ???????? ??????? ?? ???, ?? ???????? ????????? ??? ???? ????? ?? ???, ????? ???? ?????? ?? ????? ???? Microsoft ????????:
308621PRB: ??? ADO ????? ??? ???????? ?????? ???? ??? ?? ??????? ???? ??? Visual C#.???
ADO ?? ???? ??????? ?? ??????? ?????????? ?? ???????? ????? Microsoft ?? ???????? ???????? ????? ?????????? ????? ??? (SDK) ?????????:
ADO ?? ???? ?? ??????? ???????
.aspx http://msdn2.microsoft.com/en-us/library/e80y5yhx (vs.71)

???

???? ID: 311274 - ????? ???????: 11 ????? 2011 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft ADO.NET 1.1
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
??????: 
kbhowtomaster kbsqlclient kbsystemdata kbmt KB311274 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:311274

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com