Copy and Rename a Table in MS Access using VB RRS feed

  • Question

  • Hi all,

    I am trying to copy an existing MS Access table (with its structure only), and rename the original to some other name.

    Could someone share a piece of code that can perform the above operation, in VB?

    Thanks for any assistance,


    Saturday, October 15, 2005 5:19 AM

All replies

  • I think you have not posted in the rigth forum.....
    Saturday, October 15, 2005 10:19 AM
  • Sorry, it was a mistake. I have posted the issue in visual basic forum now.

    Sunday, October 16, 2005 8:37 AM
  • Here's one way to copy a table. Just delete the contents of either table afterwards.

    Dim sSQL As String = "SELECT * INTO " & sNewTableName & " FROM (" & sOldTableName & ")"

    Public Function DoExecuteNonQuery(ByVal sConnect As String, ByVal sqlCommand As String) As Boolean
       Dim cn As OleDbConnection = New OleDbConnection(sConnect)
       Dim cm As New OleDbCommand(sqlCommand, cn)
       cm.CommandText = sqlCommand
       cm = Nothing
       return True
    End Function


    I also do this directly using ADOX, but it's complex. ADOX is the only way I know of to create a table from scratch.


    Monday, October 17, 2005 4:07 PM
  • Mike,

    Thanks for the reply.

    That's really useful.

    Sunday, October 23, 2005 6:20 AM