c语言怎样连接数据库?

来源:百度知道 编辑:UC知道 时间:2024/05/11 21:32:24
c语言怎样连接数据库?

你要连什么数据库啊?
各种数据库的连接方法是不一样的。

oracle,mysql,sqlserver,sqlite,db2等等。很多种。

其中sqlite使用c写的,开源,可以放到你自己的程序中。
要是想研究一下数据库的话,可以看他。

哥们自己看吧。。。。附一源码
CWinApp theApp;
using namespace std;

CHmbAdoDBRs RfRst;
CString sSql;
CString seq, body, eng, tm, tl, icol, ecol, alc, bhmcdate;
int i;

BOOL DbOpen();
BOOL CkseqtmpSelect();
BOOL CkseqtmpUpdate();
int PrintStatus();
int SockInit();

CHmbAdoDB Sqldb;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int cnt = 0;
int nRetCode = 0;
int page = 1;
int prt_ret;
CString strDate, strTime;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode