Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
2.20/5 (3 votes)
See more:
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
Posted
Updated 8-May-14 2:46am
v2
Comments
José Amílcar Casimiro 8-May-14 8:20am    
What?
[no name] 8-May-14 8:21am    
If you think that is an understandable question, then you are mistaken. Have you tried File.Delete?

Hi sandipthummar313
Try use following code:
C#
string pathToFile = Server.MapPath("~/path_to_your_file/your_file.mdb");
if (System.IO.File.Exists(pathToFile))
{
  System.IO.File.Delete(pathToFile);
}
 
Share this answer
 
Comments
[no name] 8-May-14 9:23am    
this is nice solution. But user asking about window application where Server.MapPath will not work. For this you to use System.Environment.
Get all the non-system table names:
SQL
SELECT MSysObjects.Name AS table_name FROM MSysObjects

Then loop through each table, removing all the rows:
SQL
DELETE * FROM MyTable 
will do it.
The file will probably benefit from compacting afterwards.
 
Share this answer
 
i din't want file delete sir i want database table data delete any data i select
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900