首页 新闻 搜索 专区 学院

asp.net core 连接Oracle数据,异常,无法正常open

0
悬赏园豆:5 [已解决问题] 解决于 2020-11-27 13:47

版本说明

  • .net 5.0
  • oracle 10g

代码如下

//
user id=system;password=admin;data source=127.0.0.1/BZEY;persist security info=false;Connection Timeout=120;
//
await using (var conn = new OracleConnection(_oracleConn))
                {
                    await using (var cmd = new OracleCommand())
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = _sqlQuery;
                        cmd.Connection = conn;
                        await conn.OpenAsync();
                        await using (var read = await cmd.ExecuteReaderAsync())
                        {
                            while (await read.ReadAsync())
                            {
                                items.Add(new IcdM
                                {
                                    Code = read["code"].ToString(),
                                    Name = read["name"].ToString(),
                                    PY = read["py"].ToString(),
                                    WB = read["wb"].ToString()
                                });
                            }
                        }
                    }
                }

错误信息:
debug 打开数据库的时候报错了(await conn.OpenAsync()😉
Exception has been thrown by the target of an invocation.

The type initializer for 'OracleInternal.ServiceObjects.OracleConnectionImpl' threw an exception.

server126的主页 server126 | 初学一级 | 园豆:17
提问于:2020-11-27 10:52
< >
分享
最佳答案
0
收获园豆:5
czd890 | 大侠五级 |园豆:9788 | 2020-11-27 13:24

非常感谢您!

server126 | 园豆:17 (初学一级) | 2020-11-27 13:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册