|
From: Christian W. <chr...@rt...> - 2015-06-26 14:34:22
|
Using SMALLINT in table to store 'bool' value from C# works perfect with stand alone and embedded server.
(May be I have a char set problem (none, ASCII, UTF8,...) in DB or connection when using CHAR(1) to store a 'bool'!)
Thanks
>
> Thanks for the info
> I will do some test with a SMALLINT field.
>
> >
> > We are using SMALLINT type in our project.
> > FB EF provider also generates tables with SMALLINT fields for code-
> > first class fields.
> >
> > On 26 June 2015 at 14:49, Christian Waldmann <christian.waldmann@rte-
> > ag.ch> wrote:
> > > I am using Firebird 2.5.4, superServer and embedded, Visula Studio
> > > 2013, .Net Framework 4.5.1, .Net Provider 4.6.2
> > >
> > >
> >
> //====================================================================
> > > ======
> > > =================
> > > I have defined a table with "CyclePassed" CHAR(1) to store a
> boolean
> > > result
> > >
> > > CREATE TABLE "SampleSummaries" (
> > > "UniqueId" BIGINT DEFAULT 0 NOT NULL,
> > > "EndTestRunId" BIGINT NOT NULL,
> > > "Cycle" BIGINT NOT NULL,
> > > "LoadPressure" FLOAT,
> > > "LoadPressureMin" FLOAT,
> > > "LoadPressureMax" FLOAT,
> > > "ShutoffPressure" FLOAT,
> > > "ShutoffPressureMin" FLOAT,
> > > "ShutoffPressureMax" FLOAT,
> > > "TravelTime" FLOAT,
> > > "TravelTimeMin" FLOAT,
> > > "TravelTimeMax" FLOAT,
> > > "CyclePassed" CHAR(1)
> > > );
> > >
> > >
> > >
> >
> //====================================================================
> > > ======
> > > =================
> > > // access to table from C#
> > >
> > > bool cyclePassed = true;
> > > FbCommand command = new FbCommand();
> > >
> > > command.CommandText =
> > > "INSERT INTO \"SampleSummaries\" (" +
> > > "\"EndTestRunId\", \"Cycle\", " +
> > > "\"LoadPressure\", \"LoadPressureMin\", \"LoadPressureMax\",
> "
> > +
> > > "\"ShutoffPressure\", \"ShutoffPressureMin\",
> > > \"ShutoffPressureMax\", " +
> > > "\"TravelTime\", \"TravelTimeMin\", \"TravelTimeMax\",
> > > \"CyclePassed\"" +
> > > ") VALUES (@EndTestRunId, @Cycle, " +
> > > "@LoadPressure, @LoadPressureMin, @LoadPressureMax, " +
> > > "@ShutoffPressure, @ShutoffPressureMin, @ShutoffPressureMax,"
> +
> > > "@TravelTime, @TravelTimeMin, @TravelTimeMax, @CyclePassed
> )";
> > >
> > > command.Connection = samplesTableAdapter.Connection;
> > > command.Transaction = transaction;
> > >
> > > command.Parameters.Add("@EndTestRunId", FbDbType.BigInt).Value =
> > channelId;
> > > ...
> > >
> > > // PROBLEM A:
> > >
> >
> ======================================================================
> > > ======
> > > ==============
> > > // works with stand alone server,
> > > // but SQL error "string conversion error '49'"
> > > // {Remark: 49 is the decimal ASCII code of '1'}
> > > command.Parameters.Add("@CyclePassed", FbDbType.Boolean).Value =
> > > cyclePassed ? '1' : '0';
> > >
> > > // PROBLEM B:
> > >
> >
> ======================================================================
> > > ======
> > > ==============
> > > // works with embedded server,
> > > // but "string truncation error" with stand alone server
> > > command.Parameters.Add("@CyclePassed", FbDbType.Boolean).Value =
> > > cyclePassed;
> > >
> > > // REMARK:
> > >
> >
> ======================================================================
> > > ======
> > > ==============
> > > // works with embedded server and standalone server Firebird 2.5.3,
> > > with .Net Provider 2.0, .Net Framework 2.0, Visual Studio 2008
> > > command.Parameters.Add("@CyclePassed", FbDbType.Boolean).Value =
> > > cyclePassed;
> > >
> > > // QUESTION
> > >
> >
> ======================================================================
> > > ======
> > > ================
> > > Is this a bug or am I missing the correct usage of storing a
> 'bool'?
> > >
> > > Happy coding
> > > Christian Waldmann
> > >
>
>
>
> -----------------------------------------------------------------------
> -------
> Monitor 25 network devices or servers for free with OpManager!
> OpManager is web-based network management software that monitors
> network devices and physical & virtual servers, alerts via email & sms
> for fault. Monitor 25 devices for free with no restriction. Download
> now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
> _______________________________________________
> Firebird-net-provider mailing list
> Fir...@li...
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
|