要去下载一个Oracle的连接驱动
使用方式和OleDb一样下载
http://www.microsoft.com/downloads/details.aspx?FamilyID=4f55d429-17dc-45ea-bfb3-076d1c052524&DisplayLang=en
使用方式和OleDb一样下载
http://www.microsoft.com/downloads/details.aspx?FamilyID=4f55d429-17dc-45ea-bfb3-076d1c052524&DisplayLang=en
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb ;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
//using System.Data.OracleClient;namespace WebApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{ string StrConnection ="Provider=MSDAORA.1;User ID=windzk;password=123456;Data Source=local_tax;Persist Security Info=false";
//OracleConnection myConn = new OracleConnection(StrConnection); //myConn.Open();
string Sql="select * from TAXTABLE"; OleDbDataAdapter myCOmm = new OleDbDataAdapter(Sql,StrConnection);
DataSet oDS = new DataSet();
myCOmm.Fill(oDS, "NSRBH");
MyDataGrid.DataSource = oDS;
MyDataGrid.DataBind();
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.MyDataGrid.SelectedIndexChanged += new System.EventHandler(this.MyDataGrid_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
Page.RegisterStartupScript("msg","你好!");
} private void MyDataGrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}你必须得有ORACLE 的客户端和 ODBC的驱动才可用
OracleConnection myConnection = new OracleConnection(strConn);
myConnection.Open();
如:myConnection.Close();
如:myConnection.Close();
Provider=MSDAORA.1;Password=office;User ID=office;Data Source=oracleservice