Preventing the Teradata Connection Dialog - OLE DB Provider for Teradata

OLE DB Provider for Teradata User Guide

Product
OLE DB Provider for Teradata
Release Number
15.00
Language
English (United States)
Last Update
2018-09-28
dita:id
B035-2498
Product Category
Teradata Tools and Utilities

Preventing the Teradata Connection Dialog

To prevent the Teradata Connection dialog from displaying, the consumer sets DBPROP_INIT_PROMPT to DBPROMPT_NOPROMPT.

If the consumer uses DBPROMPT_NOPROMPT and one or more of the three required properties do not have valid data, then IDBInitialize::Initialize returns the error code DB_SEC_E_AUTH_FAILED. The returned error message is:

[OLE DB Provider for Teradata]Not enough information to log on.

Example – Visual C++

This Visual C++ example uses the DBPROP_INIT_PROMPT property.

#include <oledb.h>
#include <oledberr.h>
#include <msdasc.h>
#include <oleauto.h>
 
void main()
{
HRESULT             hr;
CLSID               clsid;
IDBInitialize       *pIDBInitialize = NULL;
IDataInitialize     *pIDataInitialize = NULL;
IDBProperties       *pIDBProperties = NULL;
DBPROPSET           rgPropertySet[1];
DBPROP              rgProperties[2];
 
//*************************************************************
// Error handling is not included in this example.  
// This is an exercise left to the user.
//*************************************************************
 
// Creating an instance of TDOLEDB
 
hr = CoCreateInstance(CLSID_MSDAINITIALIZE, 
     NULL, 
     CLSCTX_INPROC_SERVER, 
     IID_IDataInitialize, 
     (void **)&pIDataInitialize);
 
// Retrieving the class id
 
hr = CLSIDFromProgID(L"TDOLEDB", &clsid);
 
hr = pIDataInitialize->CreateDBInstance(clsid, 
     NULL, 
     CLSCTX_INPROC_SERVER, 
     NULL, 
     IID_IDBInitialize, 
    (IUnknown **)&pIDBInitialize);
 
hr = pIDBInitialize->QueryInterface(IID_IDBProperties, 
    (void **)&pIDBProperties);
 
// Setting up the properties needed to initialize the Data Source
 
// Using the Teradata Connection dialog
 
rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
rgProperties[0].dwPropertyID = DBPROP_INIT_PROMPT;
rgProperties[0].dwStatus = 0;
rgProperties[0].colid = DB_NULLID;
V_VT(&(rgProperties[0].vValue)) = VT_I2;
V_I2(&(rgProperties[0].vValue)) = DBPROMPT_PROMPT;
 
// Specifying provider string
 
rgProperties[1].dwOptions = DBPROPOPTIONS_REQUIRED;	rgProperties[1].dwPropertyID = DBPROP_INIT_PROVIDERTRING;
rgProperties[1].dwStatus = 0;
rgProperties[1].colid = DB_NULLID;
V_VT(&(rgProperties[3].vValue)) = VT_BSTR;
V_BSTR(&(rgProperties[3].vValue)) =
SysAllocString(L"SessionMode=ANSI;Enable Parser=Yes;UseXViews=YES");
rgPropertySet->cProperties = 2;
rgPropertySet->guidPropertySet = DBPROPSET_DBINIT;
rgPropertySet->rgProperties = rgProperties;
 
// Setting the properties
 
hr = pIDBProperties->SetProperties(1, rgPropertySet);
 
// Initializing the Data Source
 
// The Teradata Connection dialog displays when the program calls IDBInitialize::Initialize.
 
hr = pIDBInitialize->Initialize();
 
// This is just an example and we assume S_OK was returned
 
//-------------------------------------------------------------
//
// REST OF PROGRAM …
//
//-------------------------------------------------------------
 
// Releasing all objects at end of program
 
pIDBInitialize->Release();
gIDBProperties->Release();
}