怎样用c++/vc++建立与数据库的连接并做出该数据库的曲线图(希望有代码)数据库不必太大比如学生成绩表只要程序可用就给马上付分!!!!!!!!!!!!
谢谢了!!!!!!!!!!!!!!!!!!!

解决方案 »

  1.   

    我从没有用vc++做过数据库这是我朋友委托我做的我不会用vc++
      

  2.   

    我从没有用vc++做过数据库这是我朋友委托我做的我不会用vc++
      

  3.   

    我刚看过一个示例,是VisualC++高级开发范例解析,胡晓军等编,电子工业出版社,有一个例子跟你说的几乎一样,相信你一定会有收获。
      我有个问题:我想了几天,查了一些书,也没解决。在VC6.0中弹出的对话框对应的一个类中如何用ado连接数据库(不是基于对话框),我提出来了这个问题,在VC、MFC版上,谁能帮忙,给分。
      

  4.   

    连接数据库:
    g_pDBSource = new (CDatabase);
    CString strLinkStr;
    strLinkStr.Format("DSN=VISCTI;UID=vis;PWD=cti");
    try
    {
    g_pDBSource->OpenEx(strLinkStr,CDatabase::noOdbcDialog);
    }
    catch(CDBException *e)
    {
    AfxMessageBox(e->m_strError);
    e->Delete();
    delete g_pDBSource;
    return ;
    }
    取数据:
    if ( g_pDBSource == NULL )
    return -2;
    CRecordset* rs= NULL  ;
    try
    {
    rs=new CRecordset( g_pDBSource );
    CString strCount,strTime;
    if ( rs->Open( CRecordset::snapshot,sql)!=0 )
    {

    while( !rs->IsEOF( ) )
    {
    rs->GetFieldValue((int)0,strCount);
    nCount = atol(strCount);
    rs->GetFieldValue((int)1,strTime);
    switch(index)
    {
    case 0: //计算总数,构造结构
    m_ItemInfo[Counter].strTime = strTime ;
    m_ItemInfo[Counter].nCount0 = nCount ;
    break;
    case 1://填充结构
    m_ItemInfo[this->SearchItem(strTime)].nCount1 = nCount ;
    break;
    case 2://填充结构
    m_ItemInfo[this->SearchItem(strTime)].nCount2 = nCount ;
    break;
    case 3://填充结构
    m_ItemInfo[this->SearchItem(strTime)].nCount3 = nCount ;
    break;
    }
    Counter ++ ; if ( index == 0 )
    totalNum = Counter ;
    rs->MoveNext();
    }
    }
    else 
    {
    delete rs ;
    return FALSE ;
    }
    delete rs ;
    rs = NULL ;
    }
    catch (CDBException* e )
    {
    AfxMessageBox(e->m_strError);
    if ( rs != NULL ) delete rs ;
    e->Delete () ;
    return  FALSE;
    }
    return TRUE ;
      

  5.   

    m_strCnn="Provider=MSDAORA.1;Password="+strPassWord+
    ";User ID="+strUser+
    ";Data Source="+strServerName; m_pConnection->CursorLocation = adUseClient;
    hr = m_pConnection->Open(
    (_bstr_t)strCnn,
    (_bstr_t)_T(""),
    (_bstr_t)_T(""),
    adModeUnknown
    );
    这样就建立了连接,用的是oracle数据库,用其他数据库,strCnn有点不同,自己去查一下