建立连接后,我想将sql server中的数据库显示在combo box中,该怎么做??

解决方案 »

  1.   

    你用这个SQL语句:"select name from sysdatabases"
    然后把取得的值加到combo box中
      

  2.   


    _variant_t factoryName
    try
    {
    while(!m_pRecordset->EOF)
    {
    factoryName = (_bstr_t)m_pRecordset->GetCollect("factoryName");
    ComboBox1.AddString(factoryName);//添加到combo box
    m_pRecordset->MoveNext();
    }
    }
    catch(_com_error e)///捕捉异常
    { CString errormessage;
    errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
    AfxMessageBox(errormessage);///显示错误信息
    }
    }
      

  3.   

    while(!m_pRecordset->EOF)
    {
    strName = (_bstr_t)m_pRecordset->GetCollect("Name");
    ComboBox1.AddString(strName);//添加到combo box
    m_pRecordset->MoveNext();
    }