用DB-library链接sql Server 2000出现问题

hanhancoder 2009-04-22 08:54:49
我想通过DB-library链接sql Server 2000,并查询student表中信息,结果出现错误,代码如下:
#define DBNTWIN32
#include <stdio.h>
#include <windows.h>
#include <sqlfront.h>
#include <sqldb.h>


main()
{
DBPROCESS *dbproc;
LOGINREC *login;
RETCODE r;
DBCHAR sno[100];
DBCHAR sname[100];
DBSMALLINT score;


dbinit();
login = dblogin();

if (login == NULL)
{
return (1);
}

DBSETLUSER(login, "sa");
DBSETLPWD(login, "sa");
dbproc = dbopen(login, "LUOBO-491EBE4B5");//LUOBO-491EBE4B5服务器名,NULL或NULL字符串连接到本地的SQL SERVER
dbfreelogin(login);
if (dbproc == NULL)
{
printf("%s","sorry2\n");
return (1);
}
dbuse(dbproc, "student");
dbcmd(dbproc,"select * from a");
//dbcmd(dbproc,"delete from a where test='bb'");
//dbcmd(dbproc,"insert into a(test) values('cc')");
r = dbsqlexec(dbproc);
if (r == FAIL)
{
printf("%s","sorry3\n");
return (1);
}
while (1)
{
r = dbresults(dbproc);
if (r == SUCCEED)
{
/* Process the rows with dbnextrow() */
dbbind (dbproc, 1, CHARBIND, 0, sno);
dbbind (dbproc, 2, NTBSTRINGBIND, 0, sname);//1,2就是第几个字段
dbbind (dbproc, 3, SMALLBIND, 0, score);
//printf("%s\n","good");
while(dbnextrow (dbproc)!=NO_MORE_ROWS)
{
printf("%s\t%s\n",sname,sno);
}
}

if ((r == FAIL) || (r == NO_MORE_RESULTS))
{
break;
}
}
return (0);
}
用VC++6.0调试,结果出现如下错误:
D:\编程\TCP IP实验\实验5.1\link\link.cpp(53) : error C2664: 'dbbind' : cannot convert parameter 5 from 'char [100]' to 'unsigned char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\编程\TCP IP实验\实验5.1\link\link.cpp(54) : error C2664: 'dbbind' : cannot convert parameter 5 from 'char [100]' to 'unsigned char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\编程\TCP IP实验\实验5.1\link\link.cpp(55) : error C2664: 'dbbind' : cannot convert parameter 5 from 'short' to 'unsigned char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

请教各位高手,是什么原因?如何修改?
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanhancoder 2009-04-22
  • 打赏
  • 举报
回复
谢谢,我已经转贴了
htl258_Tony 2009-04-22
  • 打赏
  • 举报
回复
这个到VC问比较合适.VC占的比重多.

4,012

社区成员

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

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