用C代码双重连接到SQL Server [英] dual connection to sql server in c code
本文介绍了用C代码双重连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我正在使用mysql在C语言中的项目中工作,但在连接到MySQL服务器时遇到了问题.我的第一个连接有效.但是,
在另一部分中,我还需要从数据库中检索信息.我正在使用相同的代码建立其他连接.
Hi
I''m working on a project in C with mysql and I''m having a problem connecting to the MySQL server. My first connection works. However,
in another section I also need to retrieve info from the database as well. I am using the same code to make this other connection.
conn = mysql_init(NULL);
//check if there is a connection
if (conn == NULL)
{
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}
if (mysql_real_connect(conn, "localhost", "test", "test", "test", 0, NULL, 0) == NULL)
{
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
}
第二次使用此错误时,出现以下错误:
When I use this a second time I get the following error:
Unhandled exception at 0x009818c9 in simple.exe: 0xC0000005: Access violation reading location 0x00000000.
它在if(conn == NULL)
上崩溃
有谁知道为什么这行不通?
谢谢.
it crashes on the if(conn == NULL)
Does anyone have an idea why this doesn''t work?
Thanks.
推荐答案
在调用mysql_init
这篇关于用C代码双重连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文