Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • 2 weeks later...
Posted
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. :)

Posted

HOW TO: Create an Access Database Using ADOX and Visual C# .NET

 

HOW TO: Create an Access Database Using ADOX and Visual C# .NET

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...