Home > Database > Mysql Tutorial > body text

c++-vs下链接mysql数据库出错

WBOY
Release: 2016-06-06 09:38:38
Original
960 people have browsed it

mysqlc++数据库vs2010

数据库初始化没有问题,可以连接
使用mysql_query出现问题,无法查询
代码如下:
MYSQL_RES * result = NULL;
CString temp ( "select username from user_login where username = ");
MYSQL_ROW row;
CString douhao("'");
int res;
CString i_query = temp + douhao + name + douhao ;
if ((res = mysql_query(&mysql, (LPSTR)(LPCTSTR)i_query) )!= 0) //mysql_query函数为0时说明成功,mysql_query函数里面的sql语句不应该包含分号
{
mysql_errno(&mysql);
return -1;
}
else
{
res = mysql_field_count(&mysql);
if ((result = mysql_store_result(&mysql)) == NULL)
{
return -1;
}
else
{
//row = mysql_fetch_row(result);
//if (passwd == row[1])
return 0; //返回值只可能有一个,因为名字是主键
/* else
return -1;*/
}
}
mysql_free_result(result);
result = NULL;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template