Dear all,
I used the below code for databind for dropdown list:It is working fine.
if(!IsPostBack)
{
ConnStr=”Provider=msdaora;Data Source=inchndb;User Id=inchnasset;Password=inchn;”;
Conn=new OleDbConnection(ConnStr);
cmd=new OleDbCommand(“select primary_approver,Project from tbl_prj_mgr”,Conn);
Conn.Open();
ddl_prj_mgr.DataSource=cmd.ExecuteReader();
ddl_prj_mgr.DataTextField=”primary_approver”;
ddl_prj_mgr.DataValueField=”project”;
ddl_prj_mgr.DataBind();
Conn.Close();
}
But now I want to get a string from database and to display in textbox.
I used the below code it is not working.
if(!IsPostBack)
{
ConnStr=”Provider=msdaora;Data Source=inchndb;User Id=inchnasset;Password=inchn;”;
Conn=new OleDbConnection(ConnStr);
cmd=new OleDbCommand(“select empname from employee where manno=’J0695′”,Conn);
Conn.Open();
TextBox2.Text=cmd.ExecuteReader();(Error comes here)
TextBox2.Text.DataBind();
Conn.Close();
}
*Error says that: Cannot implicitly convert type ‘System.Data.OleDb.OleDbDataReader’ to ‘string’
So,how to get the value in textbox?
Thanks in advance