I\'m experiencing a seemingly random \"System resource exceeded\" exception when running my code. The idea behind my program is that a third party piece of software is conti
A couple of things I would try in your case:
// Share Mode=12 - exclusive mode (16 for multi-user)
string constr = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
"Mode=12;Data Source = C:\datafile.res;user id=;password=;";
private OleDbCommand PermanentCommand;
void KeepLinkOpen() {
if (PermanentCommand == null ||
PermanentCommand.Connection == null ||
PermanentCommand.Connection.State == System.Data.ConnectionState.Closed) {
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
PermanentCommand = new OleDbCommand("SELECT * FROM DummyTable", conn);
PermanentCommand.ExecuteReader(System.Data.CommandBehavior.Default);
}
}
void Disconnect() {
if (PermanentCommand != null) {
if (PermanentCommand.Connection != null) {
PermanentCommand.Connection.Close();
}
PermanentCommand.Dispose();
PermanentCommand = null;
}
}