下载安装oracle的驱动,代码和sql server差不多,参考:
http://wenku.baidu.com/link?url=0E3HdZaqK8HAginDnGg_AJ0KM_rvppZde04Y_GeWoLbbJWUXDRtXiMxPZiVTuAZ-xYSygiOOFtqN1GGulnt85XXLW0CY4439ufCFrQ-el3e
http://www.wzsky.net/html/Program/net/39793.html
namespace WebApplication9
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void dr_Click(object sender, EventArgs e)
{
string conn = "Data Source= orc;User ID=xuehp;Password=xue920919";
OracleConnection cn = new OracleConnection(conn);
cn.Open();
string strsql = "select count(*) from chicken where name='" + username.Text + "' and password='" + userpassword.Text + "'";
OracleCommand cmd = new OracleCommand(strsql, cn);
OracleDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
if (rd.GetValue(0).ToString() == username.Text)
{
if (rd.GetValue(1).ToString() ==userpassword.Text)
{
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('密码错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户不存在!')</script>");
}
}
}
}