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;
}
}
hunfa 0 Newbie Poster
neetika reddy -1 Newbie Poster
farooqaaa 48 Enthusiast
Lusiphur 185 Practically a Posting Shark Team Colleague Featured Poster
Geekitygeek commented: well written and spot on +1
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.