用asp.net如何连接oracle数据库!?

SeanChen 2004-06-25 08:38:49
我的环境是:
VS.net 2003
.net Framework 1.1
oracle 9i

我现在需要用asp.net 连接oracle数据库。我试过在用C#.net 创建windos application 的时候,连接成功,没有问题。然后,我换成asp.net 连接,连接的时候就报错,请那位高手帮帮忙啊!?错误如下:

Unable to load DLL (oci.dll).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DllNotFoundException: Unable to load DLL (oci.dll).

Source Error:


Line 28: this.Label1.Text = this.oracleConnection1.ConnectionString;
Line 29: DataSet ds = new DataSet();
Line 30: this.oracleConnection1.Open();
Line 31: this.oracleDataAdapter1.Fill(ds);
Line 32: int i = ds.Tables[0].DefaultView.Count;


Source File: c:\inetpub\wwwroot\testconnectdb\webform1.aspx.cs Line: 30

Stack Trace:


[DllNotFoundException: Unable to load DLL (oci.dll).]
System.Data.OracleClient.DBObjectPool.GetObject(Object owningObject, Boolean& isInTransaction)
System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(String encryptedConnectionString, OracleConnectionString options, OracleConnection owningObject, Boolean& isInTransaction)
System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionString parsedConnectionString, Object transact)
System.Data.OracleClient.OracleConnection.Open()
TestConnectDB.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\testconnectdb\webform1.aspx.cs:30
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

...全文
514 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
goody9807 2004-06-29
  • 打赏
  • 举报
回复

http://dev.csdn.net/develop/article/16/16437.shtm
www.connectionstrings.com
DSN方式连接数据库
junqilian 2004-06-29
  • 打赏
  • 举报
回复
1.是在 Oracle 9.02i 版的问题,2.你的 ORACLE_HOME 路径所在的分区格式是:NTFS格式;解决方法 到Oracle\ora92 打开Ora92的-》属性-》安全,选Authenticated Users 看下面的属性 将Read and Execute 的勾去掉,然后又勾上,确定重新启动机器
SeanChen 2004-06-29
  • 打赏
  • 举报
回复
////你的Oracle服务器是不是就装在.net开发机器上?

对阿!昨天我又试了,把程序放在别人的机器上面就可以,就我的上面不行,郁闷阿!
Tennal1020 2004-06-28
  • 打赏
  • 举报
回复
你的Oracle服务器是不是就装在.net开发机器上?
SeanChen 2004-06-25
  • 打赏
  • 举报
回复
我找了,我的oci.dll在我的oracle里面,并且它的路径还在我的环境变量里面!
SeanChen 2004-06-25
  • 打赏
  • 举报
回复
这个是我用vs.net自动生成的代码!因为我自己写的老是报上面的错误,然后我就用微软自动生成的代码!没想到还是这样!代码如下!

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TestConnectDB
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.OracleClient.OracleDataAdapter oracleDataAdapter1;
protected System.Data.OracleClient.OracleCommand oracleSelectCommand1;
protected System.Data.OracleClient.OracleCommand oracleInsertCommand1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Data.OracleClient.OracleConnection oracleConnection1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.Label1.Text = this.oracleConnection1.ConnectionString;
DataSet ds = new DataSet();
this.oracleConnection1.Open();
this.oracleDataAdapter1.Fill(ds);
int i = ds.Tables[0].DefaultView.Count;
this.oracleConnection1.Close();

}

#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.oracleDataAdapter1 = new System.Data.OracleClient.OracleDataAdapter();
this.oracleInsertCommand1 = new System.Data.OracleClient.OracleCommand();
this.oracleConnection1 = new System.Data.OracleClient.OracleConnection();
this.oracleSelectCommand1 = new System.Data.OracleClient.OracleCommand();
//
// oracleDataAdapter1
//
this.oracleDataAdapter1.InsertCommand = this.oracleInsertCommand1;
this.oracleDataAdapter1.SelectCommand = this.oracleSelectCommand1;
this.oracleDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "EMP", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("EMPID", "EMPID"),
new System.Data.Common.DataColumnMapping("EMPNAME", "EMPNAME")})});
//
// oracleInsertCommand1
//
this.oracleInsertCommand1.CommandText = "INSERT INTO EMP(EMPID, EMPNAME) VALUES (:EMPID, :EMPNAME)";
this.oracleInsertCommand1.Connection = this.oracleConnection1;
this.oracleInsertCommand1.Parameters.Add(new System.Data.OracleClient.OracleParameter(":EMPID", System.Data.OracleClient.OracleType.VarChar, 10, "EMPID"));
this.oracleInsertCommand1.Parameters.Add(new System.Data.OracleClient.OracleParameter(":EMPNAME", System.Data.OracleClient.OracleType.VarChar, 50, "EMPNAME"));
//
// oracleConnection1
//
this.oracleConnection1.ConnectionString = "user id=ad;data source=ayida;password=ad";
//
// oracleSelectCommand1
//
this.oracleSelectCommand1.CommandText = "SELECT EMPID, EMPNAME FROM EMP";
this.oracleSelectCommand1.Connection = this.oracleConnection1;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧