How to Truncate Table

jack123

New member
Local time
Today, 19:11
Joined
Jun 22, 2009
Messages
7
Hi All,

I am developing Windows Application using C#.net with MS ACCESS 2007 as my Database. During Development I have entered so many records in my database.I am having tables with datatype as AutoNumber..

Now my requirement is I want truncate tables I mean I want to delete all records and reset autonumber values..

In sql server database, Truncate keyword is there to truncate the tables...

But in MS Access I could not find this keyword...

So, Please any one tell me how to truncate tables in MS ACCESS 2007..

Thanks in advance..
 
Dim strSQL As String

strSQL = "Delete * From TableNameHere"

and then you execute that query (not sure about how the C#.NET would do it so hopefully you know how to execute queries from there).

And then you would do a compact and repair using DAO. The code to do so from inside Access is this
Code:
Public Function CompactDb()
Dim strDbNameOld As String
Dim strDBNameNew As String

strDbNameOld = "YourPathAndNameToTheFileYouWantToCompact"

        DBEngine.CompactDatabase strDBNameOld, strDBNameNew
        Kill strDBNameOld
        Name strDBNameNew As strDBNameOld
End Function

but not sure again about in C#.NET.
 

Users who are viewing this thread

Back
Top Bottom