我用的是sql server,数据源叫baoweichu
如何程序中关闭odbc数据源
并且如何恢复打开

解决方案 »

  1.   

    关闭odbc数据源????????????????????????
    打开odbc数据源???????????????????????????????????????????????????????
      

  2.   

    CDatabase db;
    db.Open(...);
    db.Close(...);
    db.Open(...);
    db.Close(...);?????????????????????
      

  3.   

    假如你用CDatabase连数据库,则它肯定有如Connect\Disconnect或Open\Close等方法的。
      

  4.   

    具体的方法看:
    http://search.csdn.net/Expert/topic/534/534578.xml?temp=.7405512
      

  5.   

    laiyiling
    你在http://community.csdn.net/Expert/topic/3848/3848746.xml?temp=.2222101教我关闭原来数据库,不知道据具体代码怎么写
    我试了很多次都不行
      

  6.   

    你用什么方式连接的就用什么方式关闭就是,一般都提供一个OPEN一个CLOSE的方法
      

  7.   

    我用的是odbc程序建立就连好了
    那应该怎么关呢?
      

  8.   

    CDatabase database;
    TRY
    {
       database.OpenEx("DSN=baoweichu; UID=sa; PWD=sa;", CDatabase::noOdbcDialog);
       database.Close();
    }CATCH(CDBException, e)
    {
        // If a database exception occured, show error msg
        AfxMessageBox("Database error: "+e->m_strError);
    }ND_CATCH;
      

  9.   

    更正下,最后一句是
     END_CATCH;
    如果对OpenEx的参数有不理解的地方,可以查MSDN.
      

  10.   

    database.Close();You must close any recordsets associated with the CDatabase object before you call this member function. Because Close does not destroy the CDatabase object, you can reuse the object .你可以用Close()来关闭数据源,
    想再连接的时候在调用open或者openExExample
    // Close the current connection
    m_dbCust.Close( );// Perhaps connect the object to a
    // different data source
    m_dbCust.OpenEx("DSN=MYDATASOURCE;UID=JOES");