After the idea of checking the cleanups of the resources, i got the answer .. -.- :
The "using" directive from C# to handle resources had no affect on the OdbcConnection object.
You have to call the Disponse method right before the next closing bracket.
This closing bracket calls the Disponse method, but - I REALLY DONT KNOW WHY - this had no affect.
using (OdbcConnection conn = new OdbcConnection(string.Format(connStr, odbcDriver,
dbq, pwd)))
{
conn.Open();
Console.WriteLine($"Conn Create");
await using OdbcCommand cmd = conn.CreateCommand();
await cmd.CommandText = "select * from [testmodel];";
cmd.Prepare();
DbDataReader reader = cmd.ExecuteReader();
Console.WriteLine($"DB EXEC COUNT '{i}'");
await conn.DisposeAsync();
}
I tried out pyhons pyodbc to reproduce, that it is not a language issue .. well
it worked fine..
with pyodbc.connect(f"Driver={dbAccessDriver};Dbq={dbFilePath};Pwd={dbPassword}") as conn:
conn: pyodbc.Connection
cmd: pyodbc.Cursor = conn.cursor()
cmd.execute("insert into [testmodel] values (?, ?)", (i, "Name " + str(i)))
cmd.commit()
Greetings to all programmers ..
Update 19.01.2021
Well, my last answer wasnt as correct as I expect.
I thought i had solved this problem, but its not.
Actually, my last solution has based on the disposed method after the using syntax of the connection and that has to work, because the triggered Disposed event is always the same.
The corrent solution is:
The problem is caused by reading from a table.
If reader were not closed OR disposed, this caused the error.
If you want to control the connections you have to go deeper and control read and write operations.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…