找不到类型或命名空间名称“Oracle”

时间:2009-12-13 14:37:34

标签: asp.net

在vs05 C#web上工作。

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

//using System.Data.OracleClient;
// ODP.NET Import(s)
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

public partial class Default2 : System.Web.UI.Page
{
    //private const string dbConnString = "Data Source=portal;User ID=aspalliancearticles; Password=minime;";

    private const string dbConnString = "Data Source=IT;User ID=jubohrm; Password=jubohrm0;";
    private const string empQuery = "select * from emp";
    private const string deptQuery = "SELECT * FROM dept";

    protected void Page_Load(object sender, EventArgs e)
    {
        PopulateTreeView();
    }

    public void PopulateTreeView()
    {
        DataSet myDataSet = GetData();
        foreach (DataRow parentRow in myDataSet.Tables["dept"].Rows)
        {
            TreeNode parentNode = new TreeNode((string)parentRow["dname"]);

            TreeView1.Nodes.Add(parentNode);

            foreach (DataRow childRow in parentRow.GetChildRows("Child"))
            {
                TreeNode childNode = new TreeNode((string)childRow["ename"]);
                parentNode.ChildNodes.Add(childNode);
            }
        }
    }

    public DataSet GetData()
    {
        OracleConnection dbConn = new OracleConnection(dbConnString);
        OracleDataAdapter empDataAdapter = new OracleDataAdapter(empQuery, dbConn);
        OracleDataAdapter deptDataAdapter = new OracleDataAdapter(deptQuery, dbConn);

        DataSet myDataSet = new DataSet();

        empDataAdapter.Fill(myDataSet, "emp");
        deptDataAdapter.Fill(myDataSet, "dept");

        myDataSet.Relations.Add("Child", myDataSet.Tables["dept"].Columns["deptno"],
            myDataSet.Tables["emp"].Columns["deptno"]);

        return myDataSet;
    }

}

要运行代码,我会收到错误消息“错误找不到类型或命名空间名称'Oracle'(您是否缺少using指令或程序集引用?)”。如何解决这个错误?

1 个答案:

答案 0 :(得分:2)

添加对相应Oracle DLL文件的引用,它应该可以工作!