怎样用c++/vc++建立与数据库的连接并做出该数据库的曲线图(希望有代码)数据库不必太大比如学生成绩表只要程序可用就给马上付分!!!!!!!!!!!!
谢谢了!!!!!!!!!!!!!!!!!!!
谢谢了!!!!!!!!!!!!!!!!!!!
解决方案 »
- CMemDC的使用
- vs2008中为什么没有类向导呢
- 同一个系统中如果一个程序执行了WSAclearup,会影响到其它程序吗?
- Installshield 2008 如何实现通过 radiobutton 选择安装
- 求<<Directshow开发指南>>电子书
- ijl15.dll读取256色jpg文件时出错
- 对话框问题,急
- 大家帮忙给我推荐一本MFC详解的书和vc详细编程实例的书
- 创建目录的时候如果存在该目录是不是会覆盖,或者如何判断某目录存在
- 我用MFC建一个CRecodset对象时选两个表,这样能增加一条记录么;另外,这样返回的记录之和是两个表的记录之积吗?
- DLL中能不能调用exe中的方法?
- unicode和多字节转换
我有个问题:我想了几天,查了一些书,也没解决。在VC6.0中弹出的对话框对应的一个类中如何用ado连接数据库(不是基于对话框),我提出来了这个问题,在VC、MFC版上,谁能帮忙,给分。
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 ;
";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有点不同,自己去查一下