怎么连接MYSQL数据库呀,急死我了,我用单个的.C文件能连接MYSQL,可是用到单文档、多文档和对话框时就不能连接MYSQL了,谁遇到过这种问题吗,快帮帮我吧!!
解决方案 »
- MFC读文件问题,我定义了一个类
- 怎么判断线条是条直线
- CInternetSession.OpenURL ,模拟提交表单,参数里面有中文字符串,行么处理?
- 怎么获得一个进程的PID?
- 同一台电电脑设备,为何vfw捕捉数据比DirectShow 少? ds:230400 vfw:大概:25可,差老远了。
- 遇到问题了,请高手帮忙~~
- 把自己的编辑框加入对话框,不是从资源编辑器里加入的,怎么进行数据交换??急,急,急?
- 请问点对话框中“×”后,执行哪段代码退出
- 求助,如何使用vfw的宏获取单祯视频
- 请问在局域网内能否通过Winsock编程绕过proxy直接访问internet?
- 求电子版本 Visual C++6.0实用教程
- 求《windows核心编程》的随书源码
我是想要在一个单文档工程中使用MYSQL(单个文件的已经能连上MYSQL了),
我不把libmySQL.dll,libmySQL.lib还有MYSQL的这两个目录include,lib都考到我的工程目录中去了(是通过:工具\选择\目录添加的),可用上#include "mysql.h"时就出现错误如下:
c:\mysql\include\mysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
(源文件代码: my_socket fd; /* For Perl DBI/dbd */)
c:\mysql\include\mysql_com.h(116) : error C2501: 'SOCKET' : missing storage-class or type specifiers
(源文件代码: my_socket fd; /* For Perl DBI/dbd */)
c:\mysql\include\mysql_com.h(116) : error C2501: 'fd' : missing storage-class or type specifiers
c:\mysql\include\mysql_com.h(180) : error C2065: 'SOCKET' : undeclared identifier
c:\mysql\include\mysql_com.h(180) : error C2146: syntax error : missing ')' before identifier 's'
(源文件代码:)
180-->int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
181--> unsigned int timeout);
(结束)
c:\mysql\include\mysql_com.h(181) : error C2059: syntax error : ')'
Error executing cl.exe.
[email protected]
感激不尽!!!!!!!!!!
一般有三种方法:
1,API函数方法,
2,ODBC数据源方法
3,ADO数据源方法
前段时间也写了一个是单文档的连MYSQL数据库的,用的API函数,你可以装一下MYSQL的程序,在它的目录下有一个自带的例程,API的话对函数了解要求高一些,如果看了例程还是不行,我可以发我的程序给你,帮你加点注释。
但是当我建立一个单文档工程时,就练不上MYSQL了
你把你的单文档连MYSQL的程序发给我看看好吗
[email protected]
帮我写一个单文档的连接MYSQL的工程,谢谢了~
用MFC连接MYSQL
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
2。app文件的InitInstance中加入
if(S_OK!=OleInitialize(NULL))
{
AfxMessageBox("初始化COM组件库错误");
}
下面就是数据库操作
_ConnectionPtr pConn;
_RecordsetPtr pRs;
CString strSQL;
pConn.CreateInstance(__uuidof(Connection));
pConn->CursorLocation=adUseClient;
strSQL="Provider=SQLOLEDB;Server=Gooyan;DataBase=SkillsBox;UID=sa;PWD=aaaaaaaa";
pConn->Open(_bstr_t(strSQL),"","",-1);pRs.CreateInstance(__uuidof(Recordset));
pRs->CursorLocation=adUseClient;
pRs->PutActiveConnection(pConn.GetInterfacePtr());pRs1.CreateInstance(__uuidof(Recordset));
pRs1->CursorLocation=adUseClient;
pRs1->PutActiveConnection(pConn.GetInterfacePtr());strSQL="select * from catalog order by cataid";
pRs->Open(_bstr_t(strSQL),vtMissing,adOpenDynamic,adLockBatchOptimistic,adCmdText);
除了include "mysql.h" 外还要 include "winsock2.h"
***************************************************************************************
我说我的思路吧
我是想要在一个单文档工程中使用MYSQL(单个文件的已经能连上MYSQL了),
我不把libmySQL.dll,libmySQL.lib还有MYSQL的这两个目录include,lib都考到我的工程目录中去了(是通过:工具\选择\目录添加的),可用上#include "mysql.h"时就出现错误如下:
c:\mysql\include\mysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
(源文件代码: my_socket fd; /* For Perl DBI/dbd */)
c:\mysql\include\mysql_com.h(116) : error C2501: 'SOCKET' : missing storage-class or type specifiers
(源文件代码: my_socket fd; /* For Perl DBI/dbd */)
c:\mysql\include\mysql_com.h(116) : error C2501: 'fd' : missing storage-class or type specifiers
c:\mysql\include\mysql_com.h(180) : error C2065: 'SOCKET' : undeclared identifier
c:\mysql\include\mysql_com.h(180) : error C2146: syntax error : missing ')' before identifier 's'
(源文件代码:)
180-->int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
181--> unsigned int timeout);
(结束)
c:\mysql\include\mysql_com.h(181) : error C2059: syntax error : ')'
Error executing cl.exe.