View Single Post
sdz
Senior Member
Join Date: Feb 2012
Old 03-12-2018 , 07:57   Re: DataPacks and queries leaking?
Reply With Quote #13

Quote:
Originally Posted by brunoronning View Post
Try this method:
It is not elegant, but it works.

PHP Code:
public void SomeFunction()
{
    
DataPack pack = new DataPack();
    
pack.WriteCell(69);
    
pack.WriteCell(420);

    
char szQuery[32];
    
Format(szQuerysizeof(szQuery), "SELECT * FROM test");
    
g_dbTest.Query(SQLCallback_TestszQuerypack);
}

public 
void SQLCallback_Test(Database dbDBResultSet results, const char[] sErrorDataPack data)
{   
    
//db not connected or something went wrong with connection:
    
if (db == null)
    {
        
LogError("(SQLCallback_Test) Database not connected or failed to connect, aboring query...");
        return;
    }
    
//query fucked up:
    
else if(results == null)
    {
        
LogError("(SQLCallback_Test) Fail at Query: %s"sError);
    }

    
int iValue1;
    
int iValue2;

    
data.Reset();
    
iValue1 data.ReadCell();
    
iValue2 data.ReadCell();
    
delete data;

    
// Your Code.

sdz is offline