Hi,
I have an MVC 5 application. I am new to MVC and Teradata.
I am trying to connect to a Teradata database using Teradata.Net.Data.Provider.
I have installed ODBC driver for Teradata (.NET Data Provider for Teradata 15.11.0.1).
I also installed Teradata.Net.Data.Provider in my project using NuGet package manager.
When I am trying to connect to Teradata I am getting the following error while opening the connection:
“An exception of type 'Teradata.Client.Provider.TdException' occurred in Teradata.Client.Provider.dll”
Message:
{"[.NET Data Provider for Teradata] [115006] Could not resolve DataSource=[MyDSNName] to an IP Address."}
Stack Tace:
at Teradata.Client.Provider.WpTcpTransport.WpHost.<AddressList>d__0.MoveNext()
at Teradata.Client.Provider.WpTcpTransport.Connect(Int32 timeout)
at Teradata.Client.Provider.WpSession.OpenTransport(Int32 connectionTimeout)
at Teradata.Client.Provider.WpSession.Open(Int32 connectionTimeout, String password)
at Teradata.Client.Provider.ExeContext`3.Open(Int32 timeout, String password)
at Teradata.Client.Provider.Connection.Open(UtlConnectionString connectionString, UInt32 timeout)
at Teradata.Client.Provider.ConnectionPool.CreateConnection(UInt32 timeout)
at Teradata.Client.Provider.ConnectionPool.GetConnectionFromPool(Object owningObject)
at Teradata.Client.Provider.ConnectionFactory.GetConnection(Object owningObject, UtlConnectionString connStr)
at Teradata.Client.Provider.TdConnection.Open()
at UM.Models.UMDbContext.GetDelegates() in C:\Users\userId\Documents\UM Audit\SourceCode\AuditApps\UM\Infrastructure\DbContext.cs:line 48
at UM.Controllers.HomeController.Home() in C:\Users\userId\Documents\UM Audit\SourceCode\AuditApps\UM\Controllers\HomeController.cs:line 21
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
Here is my code:
TdConnectionStringBuilder connectionStringBuilder =newTdConnectionStringBuilder();
connectionStringBuilder.DataSource ="MyDSNName";
connectionStringBuilder.Database ="MyDatabase";
connectionStringBuilder.UserId ="MyUserName";
connectionStringBuilder.Password ="MyPassword";
connectionStringBuilder.AuthenticationMechanism ="LDAP";
using (TdConnection cn =newTdConnection())
{
cn.ConnectionString = connectionStringBuilder.ConnectionString;
cn.Open();
TdCommand cmd = cn.CreateCommand();
cmd.CommandText ="SELECT DATE";
using (TdDataReader reader = cmd.ExecuteReader())
{
reader.Read();
DateTime date = reader.GetDate(0);
}
}
I am using the same DSN for connecting to Teradata through Teradata SQL Assistant and there it does work.
The reason why I didn't use Entity Framework for database connection is I am not able to Choose ODBC as data provider in the choose data source wizard while adding ADO.Net Entity data model.
It will be of great help if you can help me connect to Teradata database via either of the ways.
A million thanks in adnvance.
Thanks & Regards,
Dennis Thomas