数据库重新设计以后,要重新连接数据库吗? 我用Access2000做了一个数据库,原本里面有三列,现在我重新设计,添加了两列,然后在程序中相应的位置添加连接这两列数据的语句。(用list控件显示)运行程序,出现错误。将新添加的语句注释掉,程序运行正常。请问为什么呀?搞了一天了都没整明白,是不是还要重新连接数据库啊?我用的是相对路径,改成绝对路径也不行。高手来帮帮忙吧。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 连接数据库和获取数据集是分开的,你数据库连接肯定没有问题,是获取数据集错了,贴你的sql语句吧。或许是这样,你本想的到 a,b,c 但是你的语句却写成了这样 select a,b from 然后 你还getcollect(“c”)了,这样当然就错了。语句要写成select a,b,c from void CToolDlg::AddToGrid(){ ADOConn m_AdoConn; //打开数据库连接 m_AdoConn.OnInitADOConn(); CString sql; sql.Format("select * from tool order by 刀具编号 desc"); _RecordsetPtr m_pRecordset; //打开记录集 m_pRecordset=m_AdoConn.GetRecordset((_bstr_t)sql); //遍历记录集 while(m_AdoConn.m_pRecordset->adoEOF==0) { m_grid.InsertItem(0,"");//插入行 //将记录集字段中的记录添加到List Control控件中 m_grid.SetItemText(0,0,(char*)(_bstr_t)m_pRecordset->GetCollect("刀具编号")); m_grid.SetItemText(0,1,(char*)(_bstr_t)m_pRecordset->GetCollect("刀具名称")); m_grid.SetItemText(0,2,(char*)(_bstr_t)m_pRecordset->GetCollect("库存量")); m_grid.SetItemText(0,3,(char*)(_bstr_t)m_pRecordset->GetCollect("等等")); //使记录集指针指向下一记录 m_pRecordset->MoveNext(); } //断开数据库连接 m_AdoConn.ExitConnect();}以上是我的遍历集函数代码,原来只有前三个,等我加上“等等”这一列以后,就不行了 下面这句:m_grid.SetItemText(0,3,(char*)(_bstr_t)m_pRecordset->GetCollect("等等"));注释掉就运行正常,否则就会出错。 求Visual Studio 图标png大图 关于BCGControlBarPro.MDI.container加载word2007出现的问题 文件关联问题 关于控制扫描仪的问题 谁有或知道foxbase数据库管理系统的源代码? 想要做一个数据库备份的程序,请说说,方案,谢谢!!! char 与 CString转化的问题。 #import指令到底是什么? COM组件问题,请多多指教 (求助)在VC中为什么子窗口不能放入父窗口中呢? 请问怎么写Cookie 两个依赖关系的工程,是不是必须有个是库类型?
或许是这样,你本想的到 a,b,c 但是你的语句却写成了这样 select a,b from
然后 你还getcollect(“c”)了,这样当然就错了。语句要写成select a,b,c from
{
ADOConn m_AdoConn;
//打开数据库连接
m_AdoConn.OnInitADOConn();
CString sql;
sql.Format("select * from tool order by 刀具编号 desc");
_RecordsetPtr m_pRecordset;
//打开记录集
m_pRecordset=m_AdoConn.GetRecordset((_bstr_t)sql);
//遍历记录集
while(m_AdoConn.m_pRecordset->adoEOF==0)
{
m_grid.InsertItem(0,"");//插入行
//将记录集字段中的记录添加到List Control控件中
m_grid.SetItemText(0,0,(char*)(_bstr_t)m_pRecordset->GetCollect("刀具编号"));
m_grid.SetItemText(0,1,(char*)(_bstr_t)m_pRecordset->GetCollect("刀具名称"));
m_grid.SetItemText(0,2,(char*)(_bstr_t)m_pRecordset->GetCollect("库存量"));
m_grid.SetItemText(0,3,(char*)(_bstr_t)m_pRecordset->GetCollect("等等"));
//使记录集指针指向下一记录
m_pRecordset->MoveNext();
}
//断开数据库连接
m_AdoConn.ExitConnect();
}
以上是我的遍历集函数代码,原来只有前三个,等我加上“等等”这一列以后,就不行了
m_grid.SetItemText(0,3,(char*)(_bstr_t)m_pRecordset->GetCollect("等等"));
注释掉就运行正常,否则就会出错。