如何使用c#代码删除mdb文件数据而不是修复文件 [英] how to delete mdb file data using c# code not fix file

查看:203
本文介绍了如何使用c#代码删除mdb文件数据而不是修复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个mdb文件选择数据假设sa14.mdb我想要相同的mdb文件重命名sa15.mdb但是只有tabale结构我想要sa15中的数据如何使用c#windowformapplication代码在sa14中不是固定类型的posibale。 mdb我选择任何mdb

i have one mdb file select with data suppose sa14.mdb i want same mdb file with rename sa15.mdb but only tabale structure i dint want data in sa15 how it is posibale using c# windowformapplication code is not fixed type in sa14.mdb i select any mdb

推荐答案

您好sandipthummar313

请尝试使用以下代码:

Hi sandipthummar313
Try use following code:
string pathToFile = Server.MapPath("~/path_to_your_file/your_file.mdb");
if (System.IO.File.Exists(pathToFile))
{
  System.IO.File.Delete(pathToFile);
}


获取所有非系统表名称:

Get all the non-system table names:
SELECT MSysObjects.Name AS table_name FROM MSysObjects



然后遍历每个表,删除所有行:


Then loop through each table, removing all the rows:

DELETE * FROM MyTable 

将会这样做。

该文件可能会受益于之后的压缩。

will do it.
The file will probably benefit from compacting afterwards.


我不想删除文件先生我希望数据库表数据删除我选择的任何数据
i din't want file delete sir i want database table data delete any data i select


这篇关于如何使用c#代码删除mdb文件数据而不是修复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆