谢谢大哥,但这样写的话编译都是错的,您看您了解吗
ret=SQLExecDirect(kinghstmt,(SQLCHAR *)"SELECT * FROM Book where Bname='"+ bname +"'",SQL_NTS);
[Error] invalid operands of types 'SQLCHAR* {aka unsigned char*}' and 'char [50]' to binary 'operator+'
这样试试看: char cmd[1024], bname[256]; scanf("%s", bname); sprintf(cmd, "SELECT * FROM Book where Bname='%s'\0", bname); ret = SQLExecDirect(kinghstmt, (SQLCHAR *)cmd, SQL_NTS);