Export to DB – String variables

Forum Home Forums Uncategorized Issues Export to DB – String variables

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5514
    JD
    Participant

    I am using the Export to DB module, attached to a MySQL database.
    I have a tag which is a string (ASCII Text on SCADA-Administrator) that is displayed correctly on the web station.

    On the MySQL database it is shown as float and thus has no sense. How can I log it to string type or at least how can I decode the stored float value to the expected string? CONVERT and CAST functions of MySQL do not work.

    #5519
    Mikhail
    Moderator

    The idea of conversion:
    Convert the value of double type to 8 bytes. Each byte is a character.

    public static string DecodeAscii(double val)
    {
        byte[] buf = BitConverter.GetBytes(val);
        return Encoding.ASCII.GetString(buf).TrimEnd((char)0);
    }

    You should create a function in your database that performs this conversion.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.