Page 1 of 1

Database Parameter Types

Posted: Fri Feb 15, 2013 8:40 am
by simgschw
Hi,

I want to change the database connection from microsoft sql server(oleDB connection in Report) to oracle(ODP connection in Report) of a report programmatically. I could transform the datasources from the original connection to the oracle connection. It also worked for the relations and in some points for the parameters of the datasources.

The only problem I faced was when adding a StiDataParameter to a datasource one has to add the type of the parameter.
The constructor of StiDataParameter looks like this:

Code: Select all

StiDataParameter(string name, string value, int type, int size)
As the type of the parameter type is int, the automated using of this constructor is not as comfortable as I wished it could be. For parameters with the tye Integer, the corresponding value for the type is 112. When I have to transform more parameters of different types the situation gets more difficult to handle.

Can you tell me, if there's an easy way to convert parameters, or only the types of these parameters, from microsoft sql server datasources(oleDB connection in Report) to oracle(ODP connection in Report) datasources? Are there any enums for an easier handling?

Thx in advance, greetings

Re: Database Parameter Types

Posted: Fri Feb 15, 2013 12:53 pm
by Alex K.
Hello,

Unfortunately, but there is not a standart method for convert.
For each additional database pack have added the additional method.
as example:

Code: Select all

private Type ConvertDbTypeToTypeInternal(string dbType)
{
    dbType = dbType.Replace(" ", "");

    if (dbType == "DATE" || dbType.Contains("TIMESTAMP"))
        return typeof(DateTime);
    if (dbType.Contains("INTERVALDAY"))
        return typeof(TimeSpan);
    if (dbType.Contains("INTERVALYEAR"))
        return typeof(long);

    switch (dbType)
    {
        case "BFILE":
        case "BLOB":
        case "LONGRAW":
        case "RAW":
            return typeof(byte[]);

        case "FLOAT":
        case "NUMBER":
            return typeof(decimal);

        default:
            return typeof(string);

    }
}
Thank you.