首页 新闻 赞助 找找看

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.

SonyXbox的主页 SonyXbox | 菜鸟二级 | 园豆:368
提问于:2020-11-27 10:52
< >
分享
最佳答案
0
收获园豆:5
czd890 | 专家六级 |园豆:14292 | 2020-11-27 13:24

非常感谢您!

SonyXbox | 园豆:368 (菜鸟二级) | 2020-11-27 13:47
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册