Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 25 Mar 2004 @ 17:39:27 GMT


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  


Subj:   Data Access with ODBC.NET
 
From:   Anomy Anom

<-- Anonymously Posted: Thursday, March 25, 2004 12:18 -->

Has anyone managed to write a C# application that can get at the rows returned count before returning the full result set?

I can attach to teradata using ODBC, but obviously I want to interrupt a query that's going to return millions of rows.

Can anyone help?

Here's a snippet of code that might be useful.


using Microsoft.Data.Odbc;

public class QueryManager
{
   private OdbcConnection odbcConnection1 = new OdbcConnection();
   private OdbcCommand odbcCommand1 = new OdbcCommand();

   public QueryManager()
      {
          this.odbcCommand1.Connection = this.odbcConnection1;
      }

   public void RunQuery(string DSN, string queryText)
      {
          this.odbcConnection1.ConnectionString = DSN;
          this.odbcCommand1.CommandTimeout = 9000;
          this.odbcCommand1.CommandText = queryText;

          try
          {
             this.odbcConnection1.Open();
             OdbcDataReader reader = this.odbcCommand1.ExecuteReader();

             /* do something useful */

             reader.Close();

          }
          catch (OdbcException odbcex)
          {
             System.Console.WriteLine(odbcex.Message);
          }
          finally
          {
             this.odbcConnection1.Close();
          }
      }
}


     
  <Prev Next>  
<<First
<Prev
Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016