Re: How can I rename a database table?



You may want to ask this in an SQL group, but perhaps you'll have to write a stored procedure to do this sort of thing and it could be that the queries you do through the MFC interface are more restricted. I don't do much of that for sure, but I thought I'd offer up the suggestion.

Tom

<mark.tootell@xxxxxxxxxx> wrote in message news:cc9c5fa1-433a-46b0-a26c-a2e5bf636040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi

I am working on a project that uses the MFC CDatabase and CRecordset
classes to handle its interfacing with an Access database. It is
necessary for the software to rename a table within existing user
databases to ensure that they are valid for use with the new version
of the software.

As a result of my limited database and MFC knowledge I am having
difficulty finding a way of renaming the table. I have tried using the
following:

try
{
theDataBase.ExecuteSQL( "RENAME oldTableName TO newTableName");
}
catch( CDBException* e)
{
e->m_strError;
}

However, it results in the following error:
"Invalid SQL statement; Expected 'Delete', 'Insert', 'Procedure',
'Select', or 'Update'."

I have also tried:

SQLExecDirect( theDataBase.m_hdbc, ... , SQL_NTS);

But at compile time I am told that m_hdbc is protected and therefore
cannot be used in this way even though MSDN suggests that I can!?
Can anyone suggest a way of renaming this table programmatically?

Thanks


.



Relevant Pages

  • How do I rename a database table?
    ... I am working on a project that uses the MFC CDatabase and CRecordset ... As a result of my limited database and MFC knowledge I am having ... theDataBase.ExecuteSQL("RENAME oldTableName TO newTableName"); ... Can anyone suggest a way of renaming this table programmatically? ...
    (microsoft.public.vc.database)
  • How can I rename a database table?
    ... I am working on a project that uses the MFC CDatabase and CRecordset ... As a result of my limited database and MFC knowledge I am having ... theDataBase.ExecuteSQL("RENAME oldTableName TO newTableName"); ... Can anyone suggest a way of renaming this table programmatically? ...
    (microsoft.public.vc.mfc)
  • CoCreateInstance failed!!!!
    ... I am a newbie to oledb programming. ... Creation and accessing of database from Win Ce/ Embedded vc++ MFC based ... ultimate aim is to access a sql server database from sql server ce provider ...
    (microsoft.public.data.oledb)
  • Re: Compressing a .mdw file
    ... >> we copy it and compress it using Tools | Database ... >> We decided to compress it by writing a program and using ... >> then renaming the original to x.old and renaming the new ... >Dim jro As JRO.JetEngine ...
    (microsoft.public.access.security)
  • Re: Script in GUI (Was: openSUSE as a router, how to? Solved!)
    ... test if there is nothing busy with using the database, ... I understand the rpm bit. ... It's not the renaming that does it. ... The partition in question is ext3. ...
    (alt.os.linux.suse)

Loading