我正在使用 System.data.oracleclient 命名空间并将该 dll 放在我的项目的引用中
我使用连接字符串作为
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xx.x.xxx)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=xxxx)));uid=xxxx;pwd=xxxx;
在运行应用程序时,我收到响应消息
OCIEnvCreate failed with return code -1 but error message text was not available.
我不知道我卡在哪里了......
谁能给我任何指导方针来解决这个问题。
我也护目镜,但没有得到正确的解决方案。
等待您的宝贵建议和意见
更新 1:
我使用的代码是
con = new OracleConnection(conStr);
con.Open(); // connection must be openned for command
query = "insert into table1 values ('ss');
cmd = new OracleCommand(query, con);
if(cmd.ExecuteNonQuery()>0)
{
Console.WriteLine("insert sucess!");
}
con.Close();
我的堆栈跟踪错误是
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.getconnection() in D:\oracle\oracletst[via-oracleclient]\oracletst\Program.cs:line 29
at oracleTest.Program.Main(String[] args) in D:\oracle\oracletst[via-oracleclient]\oracletst\Program.cs:line 21
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()