如何使用dsn与sql server 2005数据库建立连接 [英] How to make connection with sql server 2005 database using dsn
本文介绍了如何使用dsn与sql server 2005数据库建立连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在mfc中访问sql server 2005数据库(如何)?
I want access sql server 2005 database in mfc(how)?
推荐答案
如果你检查这两个类将会很有用
- CDatabase [ ^ ]
- CRecordSet [ ^ ]
祝你好运,
OI
It will be beneficial if you check these two classes
- CDatabase[^]
- CRecordSet[^]
Good luck,
OI
首先为数据库创建dsn。
First create dsn for database.
#include "afxdb.h"
CDatabase m_database;
CRecordset m_recordset;
bool p=m_database.Open(_T(DSN name),0,0,_T("ODBC;"),1);
m_recordset.m_pDatabase = &m_database; //tell CRecordset where to find the database
m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,_T("select * from Table1"),CRecordset::appendOnly);
//Get the number of the selected records
long reCount=m_recordset.GetRecordCount();
这篇关于如何使用dsn与sql server 2005数据库建立连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文