Displaying Teradata Database Errors in VB6 using ADO

Connectivity
N/A

Displaying Teradata Database Errors in VB6 using ADO

Hi,

I'm building an application using VB6 as front-end and Teradata as backend. The problem is that i'm not able to get teradata errors in VB6 using ADO.

For eg. if executing a query referencing an non-existing table in Teradata, i get the following errors using ADO error object.

Error Number : 0
Description : ODBC driver does not support the requested properties
Source : Microsoft OLEDB provider for ODBC drivers

rather that getting the teradata error,

Error number : 3807
Description : Table/view/trigger/procedure database.tablename does not exist.

Below mentioned is my code to return the error message :

Dim objErr As ADODB.Errors
Dim errLoop As ADODB.Error
Dim strTmp As String
Set objErr = Conn.Errors
For Each errLoop In objErr
I = 1
With errLoop
strTmp = strTmp & vbCrLf & "Sequence # " & I & ":"
strTmp = strTmp & vbCrLf & " Error # : " & .NativeError
strTmp = strTmp & vbCrLf & " Description : " & .Description
strTmp = strTmp & vbCrLf & " Source : " & .Source
I = I + 1
End With
Next
msgbox strTmp

where Conn is ADODB connection object.

Appreciate your help.

Regards,
Vinod
2 REPLIES
Teradata Employee

Re: Displaying Teradata Database Errors in VB6 using ADO

I only have access to Visual Studio 2005. So I decided to use ADO (ADODB) from C#.
Following code fragment works and correctly displays

1
-3807
[NCR][ODBC Teradata Driver][Teradata Database] Object 'adsfjklajlsdkfj' does not exist.

I am using ODBC Driver for Teradata Version 3.5.0.7.

static void Main(String[] args)
{
ADODB.ConnectionClass cn = new ADODB.ConnectionClass();

cn.Open("DSN=X", "Y", "Z", 0);

ADODB.CommandClass cmd = new ADODB.CommandClass();
cmd.ActiveConnection = cn;

try
{
Object recordsAffected;
Object parameters = new object();

cmd.CommandText = "Select * from adsfjklajlsdkfj";
cmd.Execute(out recordsAffected, ref parameters, 0);
}
catch (Exception e)
{
Console.WriteLine(cn.Errors.Count);
Console.WriteLine(cn.Errors[0].NativeError);
Console.WriteLine(cn.Errors[0].Description);
}

cn.Close();
}

Re: Displaying Teradata Database Errors in VB6 using ADO

Hi,

Check the error handling options in VB 6.0. Check by trying out break in class module option.

Regds,
sachin