使用自定义的类CSetODBC(一)

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
1,理论上支持任何数据库,以Acess为例,结构如下图body.clientHeight)this.width=body.clientHeight" src="http://www.338888.com/VCShare/images/upfile/2004615211236.jpg" onmousewheel="return yuzi_img(event,this)"> 2,相关信息记录在ini或注册表中,其结构为:[数据源]DSN=TestODBCUID=adminPWD=3,动态绑定一个类,更改GetDefaultConnectCString CCharacterSet::GetDefaultConnect(){CSetODBC dlg;CString strConnect = "ODBC;" + dlg.GetConnectStr();return _T(strConnect);//动态取得ODBC//return _T("ODBC;DSN=TestODBC");}4,使用void CTestODBCDlg::OnRecordset() {CCharacterSet rs;CSetODBC dlg;rs.Open(dlg.GetWriteDBStyle());{//增加记录rs.AddNew();rs.m_Name = "典韦";rs.m_Age = 60;rs.m_country = "魏";rs.Update();}{//修改记录rs.MoveFirst();while(!rs.IsEOF()){if("典韦" == rs.m_Name){rs.Edit();rs.m_Age = 59;rs.Update();}rs.MoveNext();}}{//删除记录rs.MoveFirst();while(!rs.IsEOF()){if("典韦" == rs.m_Name){rs.Delete();rs.Requery();}rs.MoveNext();}}{//显示所有记录rs.MoveFirst();CString strOutPut;while(!rs.IsEOF()){CString strRecord;rs.m_Name.TrimLeft();rs.m_Name.TrimRight();rs.m_country.TrimLeft();rs.m_country.TrimRight();strRecord.Format("Name = %s Country = %s Age = %d ",rs.m_Name,rs.m_country,rs.m_Age);strOutPut += strRecord ;rs.MoveNext();}AfxMessageBox(strOutPut);}rs.Close();} <script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
文章标签: 数据库 ini
个人分类: VC和VC++
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭