Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 18 Oct 2010 @ 14:13:19 GMT


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


Subj:   Re: Provider does not support conversion from VarChar to System.Boolean
 
From:   Asish Muralidas

Hi,

     //****** Below is the datareader part

     using System;
     using System.Data;
     using System.Collections;
     using System.Diagnostics;

     namespace Metric.DataAccess.Common
     {
           /// 
           /// Summary description for DataReaderDO.
           /// 
       public abstract class DataReaderDO: IDataReaderDO
       {
             /// 
             ///
             /// 
         protected IDataReader m_DataReader;

                 /// 
                 /// Set the IDataReader that will be read
                 /// 
                 public virtual void SetDataReader( IDataReader dataReader )
                 {
                       m_DataReader = dataReader;
                 }

         /// 
         /// Map data reader columns to enumeration fields
         /// 
         /// 
         /// 
             protected int[] XrefColumnsToEnum( string[] enumNames )
         {
                 Hashtable columnEnum = new Hashtable(enumNames.Length);
                 int enumVal = 0;
                 foreach (string name in enumNames )
                 {
                       columnEnum[name] = enumVal++;
                 }
                 int[] columns = new int[enumNames.Length];
                 for ( int i = 0; i < columns.Length; i++ )
                   {
                         columns[i] = -1;
                   }

                 for (int i = 0; i < m_DataReader.FieldCount; i++)
                 {
                       string colName = m_DataReader.GetName(i);
                       if ( columnEnum[colName] != null )
                       {
                             int enumIdx = (int) columnEnum[colName];
                             columns[enumIdx] = i;
                       }
                 }
                 return columns;
         }

             /// 
             /// get and set the data reader
             /// 
         public virtual IDataReader DataReader
         {
           get { return m_DataReader; }
           set { m_DataReader = value; }
         }

                 /// 
                 /// called by DataReaderDOEnumerator to load the DO from the reader row
                 /// 
                 public abstract void Load();
       }

     }

     //*************Below is the Loading part using System; using System.Data;

     using Metric.Common.Entity.Hierarchy;
     using Metric.DataAccess.Common;

     namespace Metric.DataAccess.Hierarchy
     {
           /// 
           /// Summary description for UserHierarchyDO.
           /// 
           public class UserHierarchyDO: DataReaderDO
           {
                 UserHierarchy m_UserHierarchy = new UserHierarchy();

                 public UserHierarchy UserHierarchy
                 {
                       get { return m_UserHierarchy; }
                 }

                 private enum enumColumn: int
                 {
                       Tel_ID,
                       TelHierr_ID,
                       ApplicationAlias,
                       TelNode_ID,
                       IsDefault
                 }

                 private int[] m_Columns;

           public override void SetDataReader(IDataReader dataReader)
                 {
                       DataReader = dataReader;
                       m_Columns = XrefColumnsToEnum ( Enum.GetNames( typeof ( enumColumn ))
     );
                 }

                 public override void Load( )
                 {
                       m_UserHierarchy.Tel_ID =
                             m_DataReader.GetInt32( m_Columns[ (int)enumColumn.Tel_ID] );
                       m_UserHierarchy.Hierarchy.TelHierr_ID =
                             m_DataReader.GetByte( m_Columns[ (int)enumColumn.TelHierr_ID] );
                       string ht =
                             m_DataReader.GetString( m_Columns[(int)enumColumn.ApplicationAlias] );
                       if ( Enum.IsDefined( typeof(enumHierarchyType), ht ) )
                       {
                             m_UserHierarchy.Hierarchy.HierarchyType =
                                   (enumHierarchyType) Enum.Parse( typeof(enumHierarchyType), ht );
                       }
                       m_UserHierarchy.TelNode_ID =
                             m_DataReader.GetInt32( m_Columns[ (int)enumColumn.TelNode_ID] );
                       m_UserHierarchy.IsDefault =
                             m_DataReader.GetBoolean( m_Columns[ (int)enumColumn.IsDefault]
     );//**********Here is the provider error happening

                 }

           }
     }

These codes are working fine with Other databases,we cant change the code ,either we can add codes or we need to do changes on teradata


Regards

Asish



     
  <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: 15 Jun 2023