Slow Inserts over Internet using MFC
- From: "Thomas Noone" <cash@xxxxxxxxxxxx>
- Date: Thu, 21 Dec 2006 08:25:47 +0100
Hi,
I've got an MFC app, that needs about 1,5 to 2 minutes to insert 850 rows
consisting of 2 fields, into a table on an SQL Express server. The server is
accessed via odbc using its IP address.
If I trace the insert-statements using the VC debugger window, then copy
them to a query window of the SQL Express Management Studio, it takes about
15 seconds to process the same 850 inserts.
The Management Studio is on the same local pc as my app, and also connected
usinig the IP address of the remote sql server.
This would mean, using ODBC creates an 800% overhead, which I can't really
believe.
A snippet of my code:
long p;
long u,a;
ret = ::SQLAllocStmt(m_pDB->m_hdbc, &hStmt);
ret = SQLPrepare(hStmt, (unsigned char*)"INSERT INTO TABC (USERNR, ADRNR)
VALUES (?, ?)", SQL_NTS);
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
{
SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0,
0, &u, 0, &p);
SQLBindParameter(hStmt, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0,
&a, 0, &p);
for(i=0; i<=list->GetUpperBound(); i++)
{
u = m_pPointer->GetUSERNR();
a = list->GetAt(i);
ret = SQLExecute(hStmt);
}
}
As you can see, I'm preparing the statement and at least trying to avoid
unnecessary overhead.
Does anyobody have an explanation for this behaviour and maybe a solution?
Thanks a lot,
Thomas
.
- Prev by Date: slow ODBC connection Via VPN
- Next by Date: Re: slow ODBC connection Via VPN
- Previous by thread: slow ODBC connection Via VPN
- Next by thread: Cannot Update Excel File Using ODBC
- Index(es):
Relevant Pages
|