Sep 25, 2008

Connect to Oracle by ASP.NET

1. Add .net reference System.Data.OracleClient
2.
using System.Data.OracleClient;
string oradb = "Data Source=orasting;User Id=tl;Password=stl;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "select dp,dtcode,insert_time from tel where upper(ename)='" + Lbllogin.Text +"'";
OracleDataReader dr = cmd.ExecuteReader(); // C#
while (dr.Read())
{
OracleString deptcode = dr.GetOracleString(0);
OracleNumber oraclenumber1 =dr.GetOracleNumber(1);
Response.Write("OracleNumber "+oraclenumber1.ToString());
OracleDateTime oracledatetime1=dr.GetOracleDateTime(2);
Response.Write("OracleDateTime " +oracledatetime1.ToString());
if (dtcode == "1100")
{
//sdfdsfsd
}
}

0 意見: