So to recap, this all works if I use FbDbType.Float. If I change to
FbDbType.Decimal it fails with the DateTime error.
The field in the database is decimal(8,2). Andre suggested that the declaration
in the table be at least size 12? I have not been able to try this yet. But if
that is the case, then it appears that there is a bug somewhere?, and that the
error reported is itself an error?
Here is the parameters array setup:
FbParameter[] parameters =
{new FbParameter("@CartId" ,FbDbType.Integer ,0)
,new FbParameter("@CustId" ,FbDbType.Integer ,0)
,new FbParameter("@UseAltShipAddress" ,FbDbType.Integer ,0)
,new FbParameter("@ShipCost" ,FbDbType.Integer ,0)
//,new FbParameter("@ShipWeight",FbDbType.Integer ,0) //works but
truncates
//,new FbParameter("@ShipWeight",FbDbType.Decimal) //fails with
DateTime error
,new FbParameter("@ShipWeight",FbDbType.Float) //works
(some elements removed for clarity)
,new FbParameter("@ShipName" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipAddr1" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipAddr2" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipAddr3" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipCity" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipCntryAbbrev" ,FbDbType.Char ,3)
,new FbParameter("@ShipStateAbbrev" ,FbDbType.Char ,2)
,new FbParameter("@ShipZipCode" ,FbDbType.Char ,5)
,new FbParameter("@ShipPostalCode" ,FbDbType.VarChar ,12)
,new FbParameter("@ShipPhone" ,FbDbType.VarChar ,32)
,new FbParameter("@ShipEmail" ,FbDbType.VarChar ,128)
,new FbParameter("@ShipNotes" ,FbDbType.VarChar ,1024)
,new FbParameter("@ModifyDate" ,FbDbType.Char ,3)
//always 'now'
};
Here is the value assignment to the array:
parameters[ 0].Value = CartId;
parameters[ 1].Value = CustId;
parameters[ 2].Value = UseAltShipAddress;
parameters[ 3].Value = ShipCost;
parameters[ 4].Value = (float)ShipWeight; //actual field type is
decimal(8,2)
// I use this when trying the decimal fb type - does this look correct and
complete?
//parameters[ 4].Size = 8;
//parameters[ 4].Precision = 8;
//parameters[ 4].Scale = 2;
(some elements removed for clarity)
parameters[24].Value = Ship.AddrName;
parameters[25].Value = Ship.Addr1;
parameters[26].Value = Ship.Addr2;
parameters[27].Value = Ship.Addr3;
parameters[28].Value = Ship.City;
parameters[29].Value = Ship.CntryAbbrev;
parameters[30].Value = Ship.StateAbbrev;
parameters[31].Value = Ship.ZipCode;
parameters[32].Value = Ship.PostalCode;
parameters[33].Value = Ship.Phone;
parameters[34].Value = Ship.Email;
parameters[35].Value = Ship.AddrNotes;
parameters[36].Value = ModifyDate;
I compose the insert with stringbuilders:
sbFields.Append(", UseAltShipAddress ");
sbValues.Append(",@UseAltShipAddress ");
sbFields.Append(", ShipCost ");
sbValues.Append(",@ShipCost ");
sbFields.Append(", ShipWeight ");
sbValues.Append(",@ShipWeight ");
sbFields.Append(", ShipPkgCost ");
sbValues.Append(",@ShipPkgCost ");
sbFields.Append(", ShipMeth "); //replace with Ship fields
below
sbValues.Append(",@ShipMeth ");
(list abbreviated for clarity)
sbFields.Append(", ModifyDate ");
sbValues.Append(",@ModifyDate ");
sbQuery.Append("insert into ");
sbQuery.Append(MainTableName);
sbQuery.Append(" (");
sbQuery.Append(sbFields);
sbQuery.Append(")");
sbQuery.Append(" values ");
sbQuery.Append("(");
sbQuery.Append(sbValues);
sbQuery.Append(")");
sbQuery.Append(";");
Then I call the function that sets up the parameters
FbParameter[] ParamList = GetParameters();
Then I call a wrapper function that has this:
FbCommand mySqlCommand = new FbCommand(sQuery, LocalConnection);
foreach(FbParameter parameter in parameters)
{
mySqlCommand.Parameters.Add(parameter);
}
mySqlCommand.ExecuteNonQuery();
Thanks,
Kyle
----- Original Message -----
From: [email protected]
Sent: Wed, January 27, 2010, 1:00 PM
Subject: Re: [Firebird-net-provider] FbDbType.Decimal param fails
Hi,
At January-25-10, 5:19 PM, Richard Green wrote:
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider