Skip to content

Quick Symbian Factoid #1 :Fix for KErrNotSupported on RDbNamedDatabase::CreateTable.



From today I am starting a series of small code snippets or error information that I face in day-to-day Symbian C++ programming.

I was trying to create a database using RDbNamedDatabase::CreateTable. I have used this function quite some times, but for some unknown reasons it was leaving with KErrNotSupported(-5).

The code snippet that was causing issues was something like this

    CDbColSet* col = CDbColSet::NewLC();
    col->AddL(TDbCol(KColName, EDbColText, 256));// this is not correct for EDbColText
    errCode = db.CreateTable(KTableName, *col);

The main programming error is the size of column. The column type is EDbColText and its size limit is 255 and I was setting it beyond its permitted limit. So the fixed code would look like this.

    CDbColSet* col = CDbColSet::NewLC();
    col->AddL(TDbCol(KColName, EDbColText, 255));// this is correct for EDbColText
    errCode = db.CreateTable(KTableName, *col);

The proper value to set would be 255 and not 256 as confused by me. The header file, d32dbms.h, holds the size limit for each column type.