dotConnect for SugarCRM Documentation
Devart.Data.Sugar Namespace / SugarCommand Class / ExecuteReader Method / ExecuteReader() Method
Example

In This Topic
    ExecuteReader() Method
    In This Topic
    Sends the CommandText to the Connection and builds a SugarDataReader.
    Syntax
    'Declaration
     
    Public Overloads Shadows Function ExecuteReader() As SugarDataReader
    public new SugarDataReader ExecuteReader()

    Return Value

    A SugarDataReader object.
    Example
    The following example creates a SugarCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source.
    public void CreateSugarDataReader(string mySelectQuery,string sugarConnectionString)
    {
      SugarConnection sugarConnection = new SugarConnection(sugarConnectionString);
      SugarCommand sugarCommand = new SugarCommand(mySelectQuery, sugarConnection);
      sugarCommand.Connection.Open();
      SugarDataReader sugarReader = sugarCommand.ExecuteReader();
      try
      {
        while(sugarReader.Read())
        {
          Console.WriteLine(sugarReader.GetString(0));
        }
      }
      finally
      {
        sugarReader.Close();
        sugarConnection.Close();
      }
    }
    Public Sub CreateSugarDataReader(mySelectQuery As String, _
    sugarConnectionString As String)
      Dim sugarConnection As New SugarConnection(sugarConnectionString)
      Dim sugarCommand As New SugarCommand(mySelectQuery, sugarConnection)
      sugarCommand.Connection.Open()
      Dim sugarReader As SugarDataReader = sugarCommand.ExecuteReader()
      Try
        While sugarReader.Read()
          Console.WriteLine(sugarReader.GetString(0))
        End While
      Finally
        sugarReader.Close()
        sugarConnection.Close()
      End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also