数据库已经用ACCESS建立好了,已经有一个表,但是现在要求把程序运行中接受到的新数据存储到数据库中,并且是存储到一个新的表中,表的结构和已经有的那个表结构一致。数据库的连接是用的DAO,怎么样才能打开数据库,新建表把数据动态存储进去?急!急!急!

解决方案 »

  1.   

    与原表一致的话可以用Select Into NewTable From OldTable Where 0 = 1
    然后再用Insert Into NewTable Values(...)插入数据
      

  2.   

    我用的是MFC,用代码这么实现?不是用SQL语言,那个我也会,现在学要知道用C++代码怎么实现?麻烦高手告诉我,很急呀~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~怎么样新建一个表,重新命名,把数据存储到新的表中,是程序运行中实现的,动态的呀。
      

  3.   

    学习下ado
    http://www.vckbase.com/
      

  4.   

    我整个程序都是用的DAO
    不想再换ADO了
    所以麻烦帮帮忙啊~~~~~
      

  5.   

    DAO就可以的啊。查查DAO用法帮助及MSN中的
    CDaoDatabase
    CDaoTableDef
    等类的用法。
      

  6.   

    CDaoTableDef 该怎么用啊?能临时建立表吗?要建立的表何我数据库里面的存在的那个表的结构都是一样的,该怎么做啊?????
      

  7.   

    怎么,dao难道不能发送sql么?
    CDaoDatabase::Execute
    void Execute( LPCTSTR lpszSQL, int nOptions = 0 );
    throw( CDaoException, CMemoryException );ParameterslpszSQLPointer to a null-terminated string containing a valid SQL command to execute.nOptionsAn integer that specifies options relating to the integrity of the query. You can use the bitwise-OR operator (|) to combine any of the following constants (provided the combination makes sense — for example, you would not combine dbInconsistent with dbConsistent): dbDenyWrite   Deny write permission to other users.
    dbInconsistent   (Default) Inconsistent updates.
    dbConsistent   Consistent updates.
    dbSQLPassThrough   SQL pass-through. Causes the SQL statement to be passed to an ODBC data source for processing.
    dbFailOnError   Roll back updates if an error occurs.
    dbSeeChanges   Generate a run-time error if another user is changing data you are editing. 
    Note   If both dbInconsistent and dbConsistent are included or if neither is included, the result is the default. For an explanation of these constants, see the topic "Execute Method" in DAO Help.ResCall this member function to run an action query or execute an SQL statement on the database. Execute works only for action queries or SQL pass-through queries that do not return results. It does not work for select queries, which return records.For a definition and information about action queries, see the topics "Action Query" and "Execute Method" in DAO Help.Tip   Given a syntactically correct SQL statement and proper permissions, the Execute member function will not fail even if not a single row can be modified or deleted. Therefore, always use the dbFailOnError option when using the Execute member function to run an update or delete query. This option causes MFC to throw an exception of type CDaoException and rolls back all successful changes if any of the records affected are locked and cannot be updated or deleted. Note that you can always call GetRecordsAffected to see how many records were affected.Call the GetRecordsAffected member function of the database object to determine the number of records affected by the most recent Execute call. For example, GetRecordsAffected returns information about the number of records deleted, updated, or inserted when executing an action query. The count returned will not reflect changes in related tables when cascade updates or deletes are in effect.Execute does not return a recordset. Using Execute on a query that selects records causes MFC to throw an exception of type CDaoException. (There is no ExecuteSQL member function analogous to CDatabase::ExecuteSQL.)For more information about using the Execute member function, see the articleDAO Querydef: Using Querydefs in Visual C++ Programmer's Guide.
      

  8.   

    CDaoTableDef怎么用啊?有没有具体的程序例子给我看看呢?