Is there is any way where by i can excute a insert sql query carrying more than one 1 record.?  
Author Message
StephenMas





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

Am using vc++ 6.0. my application needs in such to save a 100 records in one seconds. but what i have here is the following set of code. actually i execute every insert query for each records. it takes avg 20 mins to save 1000 records. Is there is any way where by i can excute a insert sql query carrying more than one 1 record.

TRY
{
db.ExecuteSQL(sqlQuery);
}

CATCH(CDBException, pEx)
{
TCHAR buff[80];
pEx->GetErrorMessage(buff,80);
//AfxMessageBox(buff+sqlQuery);
pEx->Delete();

}
END_CATCH




Visual C++11  
 
 
cgraus





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

One way would be to pass the values as XML, use OpenXML to turn them into a table, and then use insert into. This would probably require writing a stored proc. It's not going to run within a second, I don't reckon.



 
 
Martin Richter





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

20mins for 1000 records 1 record per second

What DB are you using



 
 
StephenMas





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

Mr.Ricky martin. sorry for the wrong figs. thanks for ur highlighting. and i appreciat your Conscious. the reason i put the value there is to show that i cant able to process faster. any way am using sql server 2005. ODBC Connection. the server with in the same network. its now far away from my place.. network data traffic all ok...this is delay i guess the way i handle the query excutition. i open the database during on initial. so the databse connection remaining open after the appplication initialate. then i do all these excution while database connection open.

 
 
Viorel.





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

Maybe you should try multiple INSERT statements in a single ExecuteSQL call. I suppose statements can be separated by new-line. Try this:

db.ExecuteSQL("INSERT INTO ....\nINSERT INTO ....\nINSERT INTO ....");

Hope it helps.


 
 
StephenMas





PostPosted: Visual C++ General, Is there is any way where by i can excute a insert sql query carrying more than one 1 record.? Top

thanks mr.virol it works for me fine, now 1400 sql statement in one string takes about 5 sec to insert into database...