首页上一页 1  下一页尾页 1 条记录 1/1页
        vc连接sql数据库
                 	
                        发表在C语言图书答疑
                        2010-09-01                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           void CUpdateRecordsetDlg::OnOK() 
{
// TODO: Add extra validation here
UpdateData(true);
if(m_name.IsEmpty())
{
MessageBox("姓名不能为空!");
return;
}
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t sql;
sql = "select*from employees";
_RecordsetPtr m_pRecordset;
m_pRecordset=m_AdoConn.GetRecordSet(sql);
CString sex;
m_combo.GetLBText(m_combo.GetCurSel(),sex);
try
{
m_pRecordset->Move((long)pos,vtMissing);
m_pRecordset->PutCollect("编号",(_bstr_t)m_id);
m_pRecordset->PutCollect("姓名",(_bstr_t)m_name);
m_pRecordset->PutCollect("性别",(_bstr_t)sex);
m_pRecordset->Update();
m_AdoConn.ExitConnect();
}
catch(...)
{
MessageBox("操作失败");
return;
}
MessageBox("保存成功.");
m_grid.DeleteAllItems();
AddToGrid();
//CDialog::OnOK();
}
《visual c++开发技术大全》中450页的修改记录集数据的例子我发现有问题,按书中的例子,修改的记录集不是我鼠标点击的想要修改的记录集,不知道有没有人遇到这个问题,请大家帮助。
                
        	
        
        
    {
// TODO: Add extra validation here
UpdateData(true);
if(m_name.IsEmpty())
{
MessageBox("姓名不能为空!");
return;
}
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t sql;
sql = "select*from employees";
_RecordsetPtr m_pRecordset;
m_pRecordset=m_AdoConn.GetRecordSet(sql);
CString sex;
m_combo.GetLBText(m_combo.GetCurSel(),sex);
try
{
m_pRecordset->Move((long)pos,vtMissing);
m_pRecordset->PutCollect("编号",(_bstr_t)m_id);
m_pRecordset->PutCollect("姓名",(_bstr_t)m_name);
m_pRecordset->PutCollect("性别",(_bstr_t)sex);
m_pRecordset->Update();
m_AdoConn.ExitConnect();
}
catch(...)
{
MessageBox("操作失败");
return;
}
MessageBox("保存成功.");
m_grid.DeleteAllItems();
AddToGrid();
//CDialog::OnOK();
}
《visual c++开发技术大全》中450页的修改记录集数据的例子我发现有问题,按书中的例子,修改的记录集不是我鼠标点击的想要修改的记录集,不知道有没有人遇到这个问题,请大家帮助。

 
	
                                                 VIP会员
VIP会员 购物车
购物车

 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                







 
                     
                     
					 
						 
						 
						 
						