Code extrem langsam?? ADO Text Driver



  • Hallo Leute,

    ich hab mir ein kleines testprogramm geschrieben um den MS Text Driver für CSV files zu testen.. der code ersllt ne text datei und fügt datensätze hinzu. aber die INSERT anweisung sind ewig langsam 3 stück pro sekunden?? kann doch net sein oder?

    #include "stdafx.h"
    #include <windows.h>
    #include <stdio.h>
    
    #import "C:\Programme\Gemeinsame Dateien\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    HRESULT hr = S_OK;
        try
        {
             CoInitialize(NULL);
    		 _ConnectionPtr pConn = NULL;
              // Define string variables.
    	std::string strCon="Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=C:\\;Extensions=csv,txt;";
    		//_RecordsetPtr pRstAuthors = NULL;
    
            //Create the Connection pointer
            hr = pConn.CreateInstance((__uuidof(Connection)));
            if(FAILED(hr))
            {
                printf("Error instantiating Connection object\n");
              //  goto cleanup;
            }
    
            //Open the SQL Server connection
            hr = pConn->Open(strCon.c_str(),"","",0);
            if(FAILED(hr))
            {
                 printf("Error Opening Database object using ADO _ConnectionPtr \n");
               //  goto cleanup;
            }
    
    	  pConn->Execute("CREATE TABLE [BorisX.csv] (Vorname char(50),Nachname char(50), VarA DOUBLE, VarB DOUBLE, VarC DOUBLE, VarD DOUBLE);",NULL,adExecuteNoRecords);
    
    	  for(int i=0; i<1000000; i++){	
    	   pConn->Execute("INSERT INTO [BorisX.csv](Vorname,Nachname,VarA,VarB,VarC,VarD) VALUES ('OTTO','Mustermann',1.111,2.222,3.333,4.444);",NULL,adExecuteNoRecords);
    	   printf("Insert %i\n",i);
    	  }
           printf("Data Added Successfully\n");
    
    	//Close the database
         pConn->Close();
    
    	}
    	catch(_com_error & ce)
    	{
    	   printf("Error:%s\n",ce.Description);
    	}
    
      CoUninitialize();
      return 0;
    
    }
    

Log in to reply