相关疑难解决方法(0)

从Access数据库中删除多行

我想使用数组从访问数据库中删除多个记录.该数组是从文件名动态加载的.

然后我查询数据库,看看数据库列值是否与数组值匹配,如果没有则删除它,如果匹配则不删除它.

问题是:以下是删除所有记录的代码,与条件中的位置无关.

arrays = Directory.GetFiles(sdira, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();
    fnames.AddRange(arrays); 

    here I have use also for loop but that also didnt help me out :( like for(int u = 0; u < arrays.length; u++) { oledbcommand sqlcmd = new oledbcommand ("delete from table1 where name not in ("'+arrays[u]+"')",sqlconnection);
   I am using this one currently foreach(string name in arrays)
   {
       OleDbCommand sqlcmd = new OleDbCommand("delete from table1 where name not in ('" + name + "')", sqlconnection);
       sqlcmd.ExecuteNonQuery();                                  }`
Run Code Online (Sandbox Code Playgroud)

c# arrays ms-access

0
推荐指数
1
解决办法
1815
查看次数

标签 统计

arrays ×1

c# ×1

ms-access ×1