我有一个使用System.Data.OracleClient访问oracle数据库的C#程序。从.net访问oracle数据库时获取解决方案c#
该代码使用OracleCommand,Dataset对象。
命令结构如下
con = new OracleConnection(conStr);
con.Open();
OracleDataAdapter adp = new OracleDataAdapter("select * from sample", con);
DataSet ds = new DataSet();
adp.Fill(ds);
DataTable dt = ds.Tables[0];
con.Close();
和初始化值作为
public static String conStr = "SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=******)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=******)));uid=#####;pwd=#######;";
private OracleConnection con;
private String query;
private OracleCommand cmd;
private OracleDataReader rd;
和
我得到误差作为
堆栈跟踪:
at System.Data.OracleClient.OciHandle..ctor(OciHandle parentHandle, HTYPE handleType, MODE ocimode, HANDLEFLAG handleflags)
at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OracleClient.OracleConnection.Open()
at oracleTest.Program.showdata() in D:\oracle\oracletst[via-oracleclient]\oracletst\Program.cs:line 43
at oracleTest.Program.Main(String[] args) in D:\oracle\oracletst[via-oracleclient]\oracletst\Program.cs:line 22
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
目标站点:
{Void .ctor(System.Data.OracleClient.OciHandle, HTYPE, MODE, HANDLEFLAG)}
消息:
OCIEnvCreate failed with return code -1 but error message text was not available.
我不知道啊,我被困在
我使用Oracle 10g和DOTNET 2010 。
等待您的宝贵回复和评论......