vc访问mysql数据库的问题,急!!!

z1zhangyanan 2008-01-21 09:35:29
C:\MYSQL\INCLUDE\mysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
C:\MYSQL\INCLUDE\mysql_com.h(116) : error C2501: 'SOCKET' : missing storage-class or type specifiers
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'
C:\MYSQL\INCLUDE\mysql_com.h(181) : error C2059: syntax error : ')'

这个错误怎么调都调不过来,查看网上有很多这个错误,但都没有相应的解决办法,请帮帮忙!
...全文
1150 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
ldk13702338343 2012-05-18
  • 打赏
  • 举报
回复
小菜路过,学习了
ntmmd11 2012-05-08
  • 打赏
  • 举报
回复
咋该位置啊,我的还是那些错误没有改变啊
ComSwh 2010-09-30
  • 打赏
  • 举报
回复
我网络编程的时候也有那种错误,加了头文件还报错,后来我把头文件和其他头文件换了个位置就解决了
linuxlan 2009-04-20
  • 打赏
  • 举报
回复
#include <winsock.h>
#include <mysql.h>


在文件中调用以上头文件就可以解决mysql_com.h出现的错误!谢谢 大家的回答!收益匪浅啊!!~~~~~~~~~~~~

非常感谢!
内存泄漏 2008-02-06
  • 打赏
  • 举报
回复
是不是你的VC编译器版本问题? 一般连MYSQL只要#include <winsock.h>就可以了啊..
lmss82 2008-02-05
  • 打赏
  • 举报
回复
我加的这个。
#include <afxsock.h> // MFC socket extensions
章月庭 2008-01-23
  • 打赏
  • 举报
回复
c:\program files\microsoft platform sdk\include\
在include path中,把这个目录放到后面,把MySQL的include path 提前,试试看.
z1zhangyanan 2008-01-23
  • 打赏
  • 举报
回复
除了上边的错误还有下边这些,一共50多个错误。
c:\program files\microsoft platform sdk\include\winsock.h(40) : error C2378: 'SOCKET' : redefinition; symbol cannot be overloaded with a typedef
c:\program files\microsoft platform sdk\include\winsock.h(56) : error C2146: syntax error : missing ';' before identifier 'fd_array'
c:\program files\microsoft platform sdk\include\winsock.h(56) : error C2501: 'SOCKET' : missing storage-class or type specifiers
c:\program files\microsoft platform sdk\include\winsock.h(56) : error C2501: 'fd_array' : missing storage-class or type specifiers
c:\program files\microsoft platform sdk\include\winsock.h(63) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(744) : error C2143: syntax error : missing ';' before '__stdcall'
c:\program files\microsoft platform sdk\include\winsock.h(744) : error C2501: 'SOCKET' : missing storage-class or type specifiers
c:\program files\microsoft platform sdk\include\winsock.h(745) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(745) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(745) : error C2501: 'accept' : missing storage-class or type specifiers
c:\program files\microsoft platform sdk\include\winsock.h(747) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(750) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(750) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(752) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(754) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(754) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(754) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(757) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(757) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(759) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(762) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(762) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(764) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(767) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(767) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(769) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(772) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(772) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(774) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(777) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(777) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(781) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(792) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(792) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(793) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(800) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(800) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(803) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(806) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(806) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(811) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(821) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(821) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(824) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(827) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(827) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(832) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(835) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(835) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(839) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(842) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(842) : warning C4229: anachronism used : modifiers on data are ignored
c:\program files\microsoft platform sdk\include\winsock.h(843) : error C2059: syntax error : ')'
c:\program files\microsoft platform sdk\include\winsock.h(845) : error C2143: syntax error : missing ';' before '__stdcall'
c:\program files\microsoft platform sdk\include\winsock.h(845) : error C2501: 'SOCKET' : missing storage-class or type specifiers
c:\program files\microsoft platform sdk\include\winsock.h(845) : error C2086: 'SOCKET' : redefinition
c:\program files\microsoft platform sdk\include\winsock.h(944) : error C2146: syntax error : missing ')' before identifier 's'
c:\program files\microsoft platform sdk\include\winsock.h(944) : warning C4229: anachronism used : modifiers on data are ignored
mr.zhoux 2008-01-23
  • 打赏
  • 举报
回复
把加上winsock出错后显示的贴出来看下? mysql c api就是调用socket的,我用过很多次,
z1zhangyanan 2008-01-23
  • 打赏
  • 举报
回复
mysql_com.h不是我自己写的东西,是我安装的mysql数据库目录下include文件夹里的文件。
z1zhangyanan 2008-01-23
  • 打赏
  • 举报
回复
我用的是MySQL4.0.23,系统是XP的,mysql_com.h在我安装的MySQL目录下include文件夹里。应该不是用于linux系统的吧,我不知道啊。
内存泄漏 2008-01-23
  • 打赏
  • 举报
回复
该不会你的mysql_com.h不是用于windows下的版本吧,可能是用于unix或linux的..
z1zhangyanan 2008-01-23
  • 打赏
  • 举报
回复
问题还是没有变,为什么会这样呢?
mr.zhoux 2008-01-22
  • 打赏
  • 举报
回复
#include "winsock2.h"
#pragma comment(lib,"ws2_32")

mysq c api到socket的. 在头部加上这两句就好了
内存泄漏 2008-01-22
  • 打赏
  • 举报
回复
数据库程序怎么会用到了网络socket函数呢?真是怪..
内存泄漏 2008-01-22
  • 打赏
  • 举报
回复
你代码中怎么是用的大写的SOCKET?"? mysql_com.h 是你自己写的东西吗?
z1zhangyanan 2008-01-22
  • 打赏
  • 举报
回复
加了winsock还是报原来的错,而且还多了很多其他的错误。哪位多多帮忙指教一下,谢谢了!
shakaqrj 2008-01-22
  • 打赏
  • 举报
回复
这个是编译错误阿
socket没定义
需要假头文件
captain_x 2008-01-22
  • 打赏
  • 举报
回复
mark

4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧