ODBC or .NET Provider?

Connectivity
Enthusiast

ODBC or .NET Provider?

i am trying to connect to Teradata but not sure which one i should connect through. i dontloaded the .NET provider but i also downloaded the ODBC driver. i created a connection string for each type. but in the code behind (C#) on my web application, im not sure what my connection code should look like. Here is what i have so far, can anyone tell me what im doing wrong?

Thanks:

public static DataSet getTDSOCList() {
string TDCnnString = "Provider=Teradata; DBCName=prdbi; Database=PROTO_VAS; Uid=username; Pwd=pw";
string TDQuery = "select * from CLEV_TRN.sma_SocGroup";
OdbcConnection Conn = new OdbcConnection(TDCnnString);
OdbcCommand cmd = new OdbcCommand(TDQuery, TDCnnString);
Conn.Open();

OdbcDataReader TDReader = cmd.ExecuteReader();

Conn.Close();
6 REPLIES
Teradata Employee

Re: ODBC or .NET Provider?

Use .NET Data Provider for Teradata.

Sample Code:
using (TdConnection cn = new TdConnection())
{
TdConnectionStringBuilder conStrBuilder = new TdConnectionStringBuilder();
conStrBuilder.DataSource = "prdbi";
conStrBuilder.Database = "PROTO_VAS";
conStrBuilder.UserId = "userName";
conStrBuilder.Password = "pass";

cn.ConnectionString = conStrBuilder.ConnectionString;

cn.Open();

TdCommand cmd = cn.CreateCommand();
cmd.CommandText = "select * from CLEV_TRN.sma_SocGroup";

DataSet dataSet = new DataSet();

TdDataAdapter dataAdapter = new TdDataAdapter(cmd);
dataAdapter.Fill(dataSet);

return (dataSet);
}
Enthusiast

Re: ODBC or .NET Provider?

so here is what my code behind looks like now:

using (TdConnection cn = new TdConnection())
{
TdConnectionStringBuilder conStrBuilder = new TdConnectionStringBuilder();
conStrBuilder.DataSource = "prdbi";
conStrBuilder.Database = "PROTO_VAS";
conStrBuilder.UserId = "USER_User";
conStrBuilder.Password = "psswrd";
cn.ConnectionString = conStrBuilder.ConnectionString;
cn.Open();

TdCommand cmd = cn.CreateCommand();
cmd.CommandText = "select * from PROTO_VAS.sma_SocGroup";

DataSet ds = new DataSet();

TdDataAdapter da = new TdDataAdapter(cmd);
da.Fill(ds);

return(ds);
}

its saying invalid token "using" in class, struct or interface member declaration
also invalid token "=" for all the conStrBuilder. am i missing something? shouldnt there be like a

private static DataSet getSOCList() or something to start it off?
Enthusiast

Re: ODBC or .NET Provider?

i figured it out. thank youfor your help

Re: ODBC or .NET Provider?

can you please paste a sample code for .aspx page for above problem? that would be helpful

Thanks,

Re: ODBC or .NET Provider?

the above code showed me following error:

[.NET Data Provider for Teradata] [115006] Could not resolve DataSource=C2T to an IpAddress.

can you please help?
Teradata Employee

Re: ODBC or .NET Provider?

.NET Data Provider must resolve the "Data Source" name to an IP-Address in order for the Data Provider to establish a socket connection to Teradata Database. The error message is indicating that DNS did not return an IP address for C2T.

Use NSLOOKUP on "C2T" and "C2TCOP1"; one of them must return an IP address corresponding to a Teradata Database Node.