C
clyin
Unregistered / Unconfirmed
GUEST, unregistred user!
我用ADO+SQL Server, SQL Server的最大连接数为20,
我创建连接->打开连接->关闭连接,反复20次后,就无
法再连接了(系统报错以达到最大连接数),难道调用
Close无法关闭连接吗?
代码如下:
int main(int argc, char* argv[])
{
char lpstrConn[] = "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=dbname;Data Source=servername";
_ConnectionPtr conn;
int count = 1;
::CoInitialize(NULL);
conn.CreateInstance(__uuidof(Connection));
for (int i = 0; i < 100; i++) {
try {
conn->Open((_bstr_t)lpstrConn, (_bstr_t)"sa", (_bstr_t)"", adConnectUnspecified);
conn->Close();
}
catch(_com_error &e) {
printf("ado error: %s/n", (LPCSTR)e.Description());
}
}
::CoUninitialize();
return 0;
}
用Delphi试了以下,也是这样。Help!!!!!!!!
我创建连接->打开连接->关闭连接,反复20次后,就无
法再连接了(系统报错以达到最大连接数),难道调用
Close无法关闭连接吗?
代码如下:
int main(int argc, char* argv[])
{
char lpstrConn[] = "Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=dbname;Data Source=servername";
_ConnectionPtr conn;
int count = 1;
::CoInitialize(NULL);
conn.CreateInstance(__uuidof(Connection));
for (int i = 0; i < 100; i++) {
try {
conn->Open((_bstr_t)lpstrConn, (_bstr_t)"sa", (_bstr_t)"", adConnectUnspecified);
conn->Close();
}
catch(_com_error &e) {
printf("ado error: %s/n", (LPCSTR)e.Description());
}
}
::CoUninitialize();
return 0;
}
用Delphi试了以下,也是这样。Help!!!!!!!!