public partial class Form : System.Web.UI.Page
{
    private void connecttodb()
    {
        OracleConnection conn = new OracleConnection();
        conn.ConnectionString = "User Id=WLL; Password=wll; Data Source=WLL;";
     }
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            String CommandText = "Select DepartmentID,Department from its_department;";
            OracleDataReader odr = GetDr(CommandText, ConnectionString);
            DropDownList1.DataSource = odr;
            DropDownList1.DataTextField ="Department";
            DropDownList1.DataValueField ="DepartmentID";
            DropDownList1.DataBind();
        }
   private OracleDataReader GetDr(String sqltext, String ConnectionString)
            {
              OracleDataReader dr;
              OracleConnection oracle_conn = new OracleConnection(ConnectionString);
              OracleCommand Oracle_cmd = new OracleCommand( sqltext, conn );
               Oracle_cmd.Connection.open();
              dr = Oracle_cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
              return dr;
            }
   
}

Edited 6 Years Ago by peter_budo: Please do not use CODE SNIPPET option to post question. Use FORUM THREAD instead. When posting code use code tags

public partial class Form : System.Web.UI.Page
{
    private void connecttodb()
    {
        OracleConnection conn = new OracleConnection();
        conn.ConnectionString = "User Id=WLL; Password=wll; Data Source=WLL;";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
        {
            String CommandText = "Select DepartmentID,Department from its_department;";
            OracleDataReader odr = GetDr(CommandText, ConnectionString);
            DropDownList1.DataSource = odr;
            DropDownList1.DataTextField ="Department";
            DropDownList1.DataValueField ="DepartmentID";
            DropDownList1.DataBind();
        }
    }
    private OracleDataReader GetDr(String sqltext, String ConnectionString)
    {
        OracleDataReader dr;
        OracleConnection oracle_conn = new OracleConnection(ConnectionString);
        OracleCommand Oracle_cmd = new OracleCommand( sqltext, conn );
        Oracle_cmd.Connection.open();
        dr = Oracle_cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
        return dr;
    }
}

Issue was with brace ending Page_Load. General rule of thumb that I work with is to always ensure that when I open a brace I immediately close it and then start filling betwen the braces with my statements. This way I never forget to close a brace. Also, not sure if the posted code reflects your actual code but ensuring that tab stops are enforced (4 spaces per indent level) uniformly throughout your code makes it easier to spot and correct things like that.

Hope this helps :) Please remember to mark the thread solved once your issue is resolved.

Edit:

u have missed brace for partial class form

Incorrect but s'all good...

Add a braces before "private OracleDataReader GetDr(String sqltext, String ConnectionString)"

This was correct :twisted:

Edited 6 Years Ago by Lusiphur: n/a

Comments
well written and spot on
This article has been dead for over six months. Start a new discussion instead.