版本说明
.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.