要去下载一个Oracle的连接驱动
使用方式和OleDb一样下载
http://www.microsoft.com/downloads/details.aspx?FamilyID=4f55d429-17dc-45ea-bfb3-076d1c052524&DisplayLang=en

解决方案 »

  1.   

    using System;
    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的驱动才可用
      

  2.   

    下载一个OracleClient,安装一下必须要有Oracle的客户端,还要配网络服务名using System.Data.OracleClient;string strConn="Data Source=ddl;user id=airext;password=password";
    OracleConnection myConnection = new OracleConnection(strConn);
    myConnection.Open();
      

  3.   

    按照hx_li(小鱼儿)的方法肯定可以连通,前提是你的机器上安装了oracle(至少是客户端)并且保证在oracle中可以与目标数据库通信。补充以下虽然C#有自动回收机制但最好还是在使用完毕后关闭连接。
    如:myConnection.Close();
      

  4.   

    按照hx_li(小鱼儿)的方法肯定可以连通,前提是你的机器上安装了oracle(至少是客户端)并且保证在oracle中可以与目标数据库通信。补充以下虽然C#有自动回收机制但最好还是在使用完毕后关闭连接。
    如:myConnection.Close();
      

  5.   

    安装oracle客户端,配置相应的服务,用微软的oracle.net数据提供程序或直接用oledb连接。下面给出oledb连接字符串。
    Provider=MSDAORA.1;Password=office;User ID=office;Data Source=oracleservice