Not able to retreive results from db?

Results 1 to 2 of 2

Thread: Not able to retreive results from db?

  1. #1
    Join Date
    Dec 1969

    Default Not able to retreive results from db?

    Hi,<BR><BR>I&#039;m trying to connect to an Oracle database.I&#039;m using Oracle 9i as my database and I&#039;m not sure if I have to install anything extra to be able to connect to database and retreive the results..<BR>This is what I intend to do:<BR>When the Dropdownlist1 is selected, data from the columns is retrieved and populated into the DropdownList1.<BR>But nothing seems to be happening, I mean, nothing is populated in the dropdownlist, no matter..what everI do..please let me know what is wrong..and help me correct it..<BR>Thanks,<BR><BR>using System;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Drawing;<BR>using System.Web;<BR>using System.Data;<BR>using System.Data.OleDb;<BR>using System.Data.SqlClient;<BR>using System.Web.SessionState;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.HtmlControls;<BR><BR>namespace test<BR>{ <BR> /// &#060;summary&#062;<BR> /// Summary description for WebForm1.<BR> /// &#060;/summary&#062;<BR> public class WebForm1 : System.Web.UI.Page<BR> {<BR> protected System.Web.UI.WebControls.Label Label1;<BR> protected System.Web.UI.WebControls.DropDownList DropDownList2;<BR> protected System.Web.UI.WebControls.Label Label2;<BR> protected System.Web.UI.WebControls.Button Button1;<BR> protected System.Web.UI.WebControls.DropDownList DropDownList1;<BR> protected System.Web.UI.WebControls.Label Label3;<BR> <BR> private void Page_Load(object sender, System.EventArgs e)<BR> {<BR> <BR> } <BR> #region Web Form Designer generated code<BR> override protected void OnInit(EventArgs e)<BR> {<BR> //<BR> // CODEGEN: This call is required by the ASP.NET Web Form Designer.<BR> //<BR> InitializeComponent();<BR> base.OnInit(e);<BR> }<BR> <BR> /// &#060;summary&#062;<BR> /// Required method for Designer support - do not modify<BR> /// the contents of this method with the code editor.<BR> /// &#060;/summary&#062;<BR> private void InitializeComponent()<BR> { <BR> this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedInd exChanged);<BR> this.DropDownList2.SelectedIndexChanged += new System.EventHandler(this.DropDownList2_SelectedInd exChanged);<BR> this.Button1.Click += new System.EventHandler(this.Button1_Click);<BR> this.Load += new System.EventHandler(this.Page_Load);<BR> <BR> }<BR> #endregion<BR><BR> private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)<BR> {<BR> OleDbConnection oConn = new OleDbConnection();<BR> DataTable oTable = new DataTable(); <BR> try <BR> { <BR> oConn.ConnectionString = "blah blah";<BR> oConn.Open(); <BR> OleDbDataAdapter oDA = new OleDbDataAdapter("Select * from TEST",oConn);<BR> oDA.Fill(oTable); <BR> oConn.Close(); <BR> } <BR> catch(Exception ex) { } <BR> finally{ if (oConn.State == ConnectionState.Open) { oConn.Close(); } } <BR> // To Iterate Through Rows<BR> foreach(DataRow oRow in oTable.Rows) <BR> { <BR> Response.Write(oRow["Test_Name"].ToString()); <BR> } <BR> }<BR> private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)<BR> {<BR> <BR> }<BR> private void Button1_Click(object sender, System.EventArgs e)<BR> {<BR> <BR> }<BR> }<BR>}<BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Not able to retreive results from db?

    Maybe I&#039;m reading this wrong because there was a lot of unnecessary code there generated by VS but I dont see any where that you are binding data into either of your two listboxes. Some where in there you need a statment like<BR><BR>DropDownList1.DataSource = oTable("aTableNameGoesHere")<BR>DropDownList1.Data Bind

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts