Answer the question
In order to leave comments, you need to log in
Table Creation Error "Table 'name' cannot be locked; it is being used by user '(no data)'.. How to solve?
Comp. Windows Server 2008 r2 x64, when trying to create table " create table [" , executing the command
gives intermittent error:
System.Data.OleDb.OleDbException: Cannot lock table 'table_name'; it is used by user '(n/a)' on machine '(n/a)'.
compiles under x86 (when compiling anyCPY - does not find providers)
And on 32-bit machines everything is fine.
DSN added to SysWOW64\odbcad32.exe - to no avail.
ProcessExplorer - does not find by name
And the error is not constant 7 out of 10.
I strongly suspect that digging towards OS settings.
.....
if (File.Exists(file_name)) File.Delete(file_name);
provider = "Microsoft.Jet.OLEDB.4.0"; // разные варианты
dBase = "dBase 5.0"; // разные варианты
string conn_string = @"Provider=" + provider + @";Data Source=""{0}"";" +
"Extended Properties=" + dBase + ";Persist Security Info=False";
using (OleDbConnection conn = new OleDbConnection(string.Format(conn_string, dir_name)))
{ string query = " create table [" + f_name + "] (";
query += "id integer, name char(254))";
using (OleDbCommand cmd = new OleDbCommand("", conn))
{
conn.Open();
cmd.CommandText = query;
cmd.ExecuteNonQuery(); // здесь ошибка
query = "insert into [" + f_name + "] (id, name) values(?,?)";
cmd.CommandText = query;
for (int i = 0; i < 20; i++)
{ cmd.Parameters.AddWithValue("id", i);
cmd.Parameters.AddWithValue("name", i.ToString());
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
MessageBox.Show("All OK");
}
}
.................
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question