How to: Delete a Database (Programmatically)
In this topic, you will learn how to delete a SQL Server Compact 3.5 database. Because SQL Server Compact 3.5 databases are files in the file system, you delete a SQL Server Compact 3.5 database by deleting the file.
Procedures for SQL Server Compact 3.5
To delete a database
Call the System.IO.File.Delete method and pass in the path and file name of the SQL Server Compact 3.5 database.
File.Delete("Test.sdf");
Example
This example deletes the existing SQL Server Compact 3.5 database named Test.sdf.
using System.IO;
namespace MySQLCEApplication
{
class Program
{
static void Main(string[] args)
{
// Call the File class Delete method to delete the database.
File.Delete("Test.sdf");
}
}
}
Imports System.IO
Module Module1
Sub Main()
'Call the File class Delete method to delete the database.
File.Delete("Test.sdf")
End Sub
End Module
See Also
Other Resources
Working with Databases (SQL Server Compact)