日期:2014-05-16  浏览次数:20702 次

求 vc 访问postgresql 实例一份 谢谢!
如题

谢谢!

------解决方案--------------------
手册中的例子。
MySQL官方文档 http://dev.mysql.com/doc/refman/5.1/zh/index.html


C/C++ code
char query[1000],*end;

end = strmov(query,"INSERT INTO test_table values(");
*end++ = '\'';
end += mysql_real_escape_string(&mysql, end,"What is this",12);
*end++ = '\'';
*end++ = ',';
*end++ = '\'';
end += mysql_real_escape_string(&mysql, end,"binary data: \0\r\n",16);
*end++ = '\'';
*end++ = ')';

if (mysql_real_query(&mysql,query,(unsigned int) (end - query)))
{
   fprintf(stderr, "Failed to insert row, Error: %s\n",
           mysql_error(&mysql));
}