C# / Access 2002 - Problem renaming table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cbbibleboy
    New Member
    • Apr 2007
    • 29

    C# / Access 2002 - Problem renaming table

    Hey! I'm trying to rename a table in Access through C#, and I've tried using the “SELECT * INTO new_table_name FROM old_table_name” method, but I'm afraid it is not working. My exact code is:

    Code:
    OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ")", clsDatabase.Connection);
    CMD.ExecuteNonQuery();
    Yet an exception is thrown every time:

    -------------------------------------------
    Syntax error in FROM clause.
    -------------------------------------------

    It's very mysterious and I'd really appreciate your help. I'm using C# 2005 with a 2002-formatted Microsoft Access database on Windows XP. Thanks!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Originally posted by cbbibleboy
    Hey! I'm trying to rename a table in Access through C#, and I've tried using the “SELECT * INTO new_table_name FROM old_table_name” method, but I'm afraid it is not working. My exact code is:

    Code:
    OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ")", clsDatabase.Connection);
    CMD.ExecuteNonQuery();
    Yet an exception is thrown every time:

    -------------------------------------------
    Syntax error in FROM clause.
    -------------------------------------------

    It's very mysterious and I'd really appreciate your help. I'm using C# 2005 with a 2002-formatted Microsoft Access database on Windows XP. Thanks!
    Code:
    OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ";", clsDatabase.Connection);
    CMD.ExecuteNonQuery();

    Comment

    Working...