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
Recommended Answers
Jump to PostOnly thing I'm going to say here is... when did DaniWeb become the equivalent of a compiler's built-in syntax and error checker?
If you have a specific problem with the code or it's not working in an expected way it would be appreciated if you would provide the error …
All 2 Replies
pritesh2010
30
Posting Whiz in Training
Lusiphur
185
Practically a Posting Shark
Team Colleague
Featured Poster
Ezzaral
commented:
Agreed.
+13
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.