SimDuck Posted October 29, 2004 Posted October 29, 2004 Hi, I am trying to delete a database using the SQL query string "DROP DATABASE Copy of Account_Details". I have looked for some help but have been unable to find some. Dim strConnString As New Connection Dim strDir As New Directory Dim strConn As String Dim strCommand As String strCommand = "DROP DATABASE Copy of Account_Details.mdb" strConn = strConnString.ConString("copy of account_details.mdb", strDir.RootDir) Dim myConnection As New OleDbConnection(strConn) Dim myCommand As New OleDbCommand(strCommand, myConnection) myConnection.Open() myCommand.ExecuteNonQuery() myConnection.Close() When I get to the executenonquery command, I get an unhandled error in the dll. What am I doing wrong and how do I successfully delete/ remove this database? I am also trying to add new databases (sql = "CREATE DATABASE Test") using code but when the myconnection.open code is excecuted, I get an error saying the conenction is not open. How do I create a database on the fly using sql code? Thank you in advance for your answeres. Quote
Administrators PlausiblyDamp Posted October 29, 2004 Administrators Posted October 29, 2004 What database are you using? The .mdb looks like access - in which case this code will not work as it is specific to SQL Server. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
stustarz Posted October 30, 2004 Posted October 30, 2004 If it is an access database then you can always use System.IO.File.Delete(PathAsString) Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
SimDuck Posted November 7, 2004 Author Posted November 7, 2004 What database are you using? The .mdb looks like access - in which case this code will not work as it is specific to SQL Server. I am trying to use an Access Databse, but I am not concerned with which type of database I use. How do I create a SQL database via code as I don't have any 3rd party SQL Database software? If it is an access database then you can always use System.IO.File.Delete(PathAsString) This will work if I want to delete the database, but how do I create one? I can use this to create but then when I try to connect to the database, I get an error. Thank you again. :) Quote
Joe Mamma Posted November 7, 2004 Posted November 7, 2004 HOW TO: Create an Access Database Using ADOX and Visual C# .NET HOW TO: Create an Access Database Using ADOX and Visual C# .NET Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.