Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 619979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:42:48+00:00 2026-05-13T18:42:48+00:00

I have a Firebird stored procedure that accepts Decimal(9,6) values for Latitude and Longitude

  • 0

I have a Firebird stored procedure that accepts Decimal(9,6) values for Latitude and Longitude parameters. It’s used to create a contact profile for a user.

When I try to create and use these decimal parameters, I get a conversion error:

Value was too large or too small for an Int32.

Here’s how I create the ADO.Net connection:

FbConnection dbConn = new FbConnection(ConnectionString);

And further on, here’s where I set up the command:

        IDbCommand command = _Connection.CreateCommand();
        command.Connection = _Connection;
        command.CommandText = "CREATECONTACT";
        command.CommandType = CommandType.StoredProcedure;

The code I’m using to create the ADO.Net parameters looks like this:

IDataParameter param21 = command.CreateParameter();
param21.ParameterName = "GEOLAT";
param21.DbType = DbType.Decimal;
param21.Value = 3.14m;

After all the parameters are added I call command.ExecuteScalar() to get the value of the ContactId that was (hopefully) just created.

int contactId = Convert.ToInt32(command.ExecuteScalar(), CultureInfo.InvariantCulture);

It isn’t the Convert.ToInt32 that causes the problem. The exception is thrown from ExecuteScalar(). I get the same error if the command looks like this:

object result = command.ExecuteScalar();

The procedure works fine if the values for GeoLat and GeoLong are integer values (such as 72 or 0), but if I try to pass a decimal value, it fails. For example:

IDataParameter param21 = command.CreateParameter();
param21.ParameterName = "GEOLAT";
param21.DbType = DbType.Int32;
param21.Value = 12;

Am I doing something wrong here?

I’m using the Firebird .NET data provider 2.5.1 against a Firebird 2.1.3 database.

UPDATE: At @bluecoder’s request, I tried to build the .NET data provider from the source code. But I get a compile error at line 731 of GdsStatement.cs.

int processedItems = (rowDescs[part] != null ? rowDescs[part].Count : 0);

The error is:

There exist both implicit conversions from “short” to “int” and from “int” to “short”.

Changing line 731 to this:

int processedItems = (rowDescs[part] != null ? (int) rowDescs[part].Count : 0);

Allows the code to compile on my machine.

After making this code change, I was able to run my tests and use decimals in my stored procedure successfully.

It appears that the trigger for the error is that I return the number of rows affected by my update statement as part of the procedure.

UPDATE2: Here’s the full source for the SQL stored procedure. It’s used to create an hCard record in my database.

SET TERM ^ ;
RECREATE PROCEDURE CREATECONTACT (
 TEMPLATECODE     SMALLINT,
 CREATEUSERID     INTEGER,
 CREATEDATE       TIMESTAMP,
 SECURITYCODE     SMALLINT,
 LINKTEXT         VARCHAR(255),
 GUID             VARCHAR(200),
 GIVENNAME        VARCHAR(200),
 FAMILYNAME       VARCHAR(200),
 ADDITIONALNAME   VARCHAR(200),
 HONORIFICPREFIX  VARCHAR(200),
 HONORIFICSUFFIX  VARCHAR(200),
 NICKNAME         VARCHAR(200),
 PHOTOLOCALFILEID INTEGER,
 LOGOLOCALFILEID  INTEGER,
 BIRTHDAY         TIMESTAMP,
 JOBTITLE         VARCHAR(200),
 "ROLE"           VARCHAR(200),
 ORGANIZATION     VARCHAR(255),
 NOTE             BLOB SUB_TYPE TEXT,
 GEOLAT           DECIMAL(9,6),
 GEOLONG          DECIMAL(9,6))
RETURNS (
 ENTITYID         INTEGER)
AS 
BEGIN
EXECUTE PROCEDURE CreateEntity :TEMPLATECODE, :CREATEUSERID, :CREATEDATE, :SECURITYCODE, :LinkText 
    RETURNING_VALUES EntityId;

INSERT INTO CONTACT (EntityId, GUID, GIVENNAME, FAMILYNAME, ADDITIONALNAME, 
HONORIFICPREFIX, HONORIFICSUFFIX, NICKNAME, PHOTOLOCALFILEID, LOGOLOCALFILEID, 
BIRTHDAY, JOBTITLE, "ROLE", ORGANIZATION, NOTE, GEOLAT, GEOLONG)
VALUES (:EntityId, :GUID, :GIVENNAME, :FAMILYNAME, :ADDITIONALNAME, 
:HONORIFICPREFIX, :HONORIFICSUFFIX, :NICKNAME, :PHOTOLOCALFILEID, 
:LOGOLOCALFILEID, :BIRTHDAY, :JOBTITLE, :ROLE, :ORGANIZATION, :NOTE, 
:GEOLAT, :GEOLONG);
SUSPEND;
END^
SET TERM ; ^

UPDATE3: I just tried this with the new Firebird Client 2.5.2 release and it’s still having a problem. I think this is a bug. I’m going to report it on the Firebird Tracker.

UPDATE4: Oops. I discovered I had a stale reference to Firebird Client 2.5.1 in my GAC. Firebird Client 2.5.2 does fix the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:42:49+00:00Added an answer on May 13, 2026 at 6:42 pm

    I just discovered that I had a stale reference to Firebird Client 2.5.1 in my GAC. After removing this reference, I was able to run my test cases successfully.

    The .NET Provider for Firebird version 2.5.2 does not have the problem I described in my question. The solution is to upgrade to the latest version of the .NET Provider for Firebird.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a relatively large application that is strongly tied into Firebird (stored procedures,
I have a desktop (winforms) application that uses a Firebird database as a data
I need to create a Firebird Database programmatically using DBExpress. I have done this
my goal is to write a stored proc that can collect all field values
Currently, I have an application that uses Firebird in embedded mode to connect to
I need a stored procedure which in parameter have name of table(varchar) and it
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I ran across the following in a stored procedure: for select 1 from scan_queue
We have a data collection system that collects measurements from environmental sensors that measure
I have converted a database from MySQL to Firebird, all tables name and field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.