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

2020-11-27 13:15发布

问题:

版本说明

  • .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()