.NET unable to fetch the data from teradata

Third Party Software
Enthusiast

.NET unable to fetch the data from teradata

hi

I am using .NET as a frontend and trying to connect to teradata edw of our company for accessing data.

i am using odbc. following is the code:
protected void Button1_Click(object sender, EventArgs e)
{
Microsoft.Data.Odbc.OdbcConnection oODBCConnection;
OdbcCommand cmd;
OdbcDataReader rdr;

string sConnString = "Dsn=TDEDW1;Driver={Teradata};uid=appl_student_t_04; Database = t_student04_1;Pwd = Training_04";

oODBCConnection = new OdbcConnection(sConnString);
oODBCConnection.Open();

string strSQL = "Select ShipToCustomer From T_STUDENT04_1.orderdetails where OrderID=10926 and UnitPrice=6.00";

cmd = new OdbcCommand(strSQL, oODBCConnection);

rdr = cmd.ExecuteReader();

TextBox1.Text = rdr.GetName(0);
TextBox2.Text = rdr.GetString(0);
rdr.Close();
cmd.Dispose();
oODBCConnection.Close();

the problem is it shows the column name, but says no data exist for a particular row/column.
the same query gives data when used in Teradata SQL assistant.

textbox1 gives the field shiptocustomer but for textbox2 vs says no data exist.

thank you :-)

regards
Akhshay Gandhi.
1 REPLY
Enthusiast

Re: .NET unable to fetch the data from teradata

hi everyone

i found the error... its because i was not using rdr.read() after rdr = cmd.executereader();

thank you
:-)