用DB-library链接sql Server 2000出现问题
我想通过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
请教各位高手,是什么原因?如何修改?