我有一个 ado.net 代码清单:
OleDbConnection oconn = new OleDbConnection();
// oconn.ConnectionString ="Driver={Microsoft Visual FoxPro Driver};Provider=vfpoledb.1;SourceType=DBF;SourceDB=" + pelna_sciezka + ";Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
oconn.ConnectionString = "Provider=vfpoledb.1;Data Source=" + pelna_sciezka + ";Collating Sequence=machine";
oconn.Open();
OleDbCommand ocmd = oconn.CreateCommand();
string na = TBNazwaKonta.Text.Replace("\n","");
na = na.Replace("\r","") ;
string ks2 = ks.Replace("\n","");
ks2 = ks2.Replace("\r", "");
OleDbCommand dbCmdNull = oconn.CreateCommand();
dbCmdNull.CommandText = "SET NULL OFF";
dbCmdNull.ExecuteNonQuery();
string zapytanie = @"insert into " + @pelna_sciezka + @" (rk, Na,Ks) values (0,'" + na + "','" + ks2 +"')";
ocmd.CommandText = zapytanie;
ocmd.ExecuteNonQuery();
oconn.Close();
它运行良好,没有任何问题。但是我使用的 dbf 文件正在被另一个程序使用。为什么如果我执行查询并关闭连接,dbf 文件仍由程序保存?如果有人想打开它,错误消息是“文件访问被拒绝”。只有当我关闭应用程序时,另一个才能访问