By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,163 Members | 944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,163 IT Pros & Developers. It's quick & easy.

C# / Access 2002 - Problem renaming table

P: 29
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:

Expand|Select|Wrap|Line Numbers
  1. OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ")", clsDatabase.Connection);
  2. 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!
Aug 6 '07 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,392
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:

Expand|Select|Wrap|Line Numbers
  1. OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ")", clsDatabase.Connection);
  2. 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!
Expand|Select|Wrap|Line Numbers
  1. OleDbCommand CMD = new OleDbCommand("SELECT * INTO " + _newName + " FROM " + _oldName + ";", clsDatabase.Connection);
  2. CMD.ExecuteNonQuery();
Aug 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.