Hi,
I am try to create a DSN using C# code and trying to connect to Teradata, i am getting the following error
[.Net provider for teradata][115006] could not resolve datasource ="DSNNAME" to an IPaddress.
private const string ODBC_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBC.INI\\";
private const string ODBCINST_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBCINST.INI\\";
var datasourcesKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + "ODBC Data Sources");
if (datasourcesKey == null) throw new Exception("ODBC Registry key for datasources does not exist");
datasourcesKey.SetValue("DSNNAME", "TERADATA");
string driverName = "Teradata";
var driverKey = Registry.LocalMachine.CreateSubKey(ODBCINST_INI_REG_PATH + driverName);
string driverPath = driverKey.GetValue("Driver").ToString();
var dsnKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + dsnName);
if (dsnKey == null) throw new Exception("ODBC Registry key for DSN was not created");
dsnKey.SetValue("Description", "TEST DSN FOR TERADATA");
dsnKey.SetValue("Driver", driverPath);
dsnKey.SetValue("LastUser", Environment.UserName);
dsnKey.SetValue("Server", "XXX.XXX.com");
dsnKey.SetValue("Trusted_Connection", "YES");
string user_nam = System.Environment.UserName;
Teradata.Client.Provider.TdConnection Connection = null;
Connection = new TdConnection("Data Source=" + DSNNAME+ ";User ID=" + user_nam + ";IntegratedSecurity=True;");
Connection.Open();
After connection, i am getting the following error
[.Net provider for teradata][115006] could not resolve datasource ="DSNNAME" to an IPaddress.
↧