Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 08 Aug 2007 @ 13:53:46 GMT


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


Subj:   Re: MTDP: EM_NOHOST(224) error
 
From:   Henderson, John

John,

I too took a while getting used to using the .Net Provider for Teradata in VS 2005. Here's an example of my code ? hope if helps. This code shows an example of hitting a box listed in the hosts file (TeradataTest), and one that is not.

In c:\windows\system32\drivers\etc\HOSTS:

     {IP Address}      DBCT       ? This is the IP address of the
                                    server followed by {TAB}
                                    then the HOSTS entry name.

In VS Web.Config file:

     < configuration >
           < appSettings >
                 < !-- Specify .Net Provider for Teradata address information -- >
                 < add key="TeradataProd" value="{the web server address}"/ >
     ? You would use ?td1cop1.biz.mycompany.com?
                 < add key="TeradataTest" value="{the HOSTS file entry name}"/ >
                 Etc?
                 Etc?
           < /appSettings >
     < /configuration >

In Default.aspx.vb:

     Imports System
     Imports System.Data
     Imports System.Data.Common
     Imports Teradata.Client.Provider

Then in the button1_Click event, I have:

        Dim TQLConnection As New TdConnection
        Dim TQLConnectionStringBuilder As TdConnectionStringBuilder
        TQLConnectionStringBuilder = New TdConnectionStringBuilder

        ? In this section, I use a WebConfig AppSetting to point to
     different boxes.  TeradataProd has a web address of
  ? the server for the production box, and it's not listed in the HOSTS
     file.  TeradataTest is listed in the HOSTS
  ? file, and the HOSTS listing is the servers IP address and the name
     DBCT.
        If ckTest.Checked = False Then
            TQLConnectionStringBuilder.DataSource =
     System.Configuration.ConfigurationManager.AppSettings("TeradataProd")
        Else
            TQLConnectionStringBuilder.DataSource =
     System.Configuration.ConfigurationManager.AppSettings("TeradataTest")
        End If

        TQLConnectionStringBuilder.UserId = "myid"          ? hardcoded,
     but could use a supplied textbox value instead.
        TQLConnectionStringBuilder.Password = "mypw"        ? hardcoded,
     but could use a supplied textbox value instead.
        TQLConnectionStringBuilder.AccountString = "acctinfo"
        TQLConnectionStringBuilder.PersistSecurityInfo = True

        TQLConnection.ConnectionString =
     TQLConnectionStringBuilder.ConnectionString

        Try
            TQLConnection.Open()

        Catch ex As Exception
            ? Allows you to catch and display errors on the webpage
     during connection attempts.
            Response.Write("Error from connection attempt = " &
     ex.Message.ToString() & "
") End Try If TQLConnection.State = ConnectionState.Open Then {Code here if connection is open} Else {Code Here if connection is not open} End If

Thanks,

John H



     
  <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