Code snippets: binary data insertion

  • Nobody/Anonymous


    Can someone give me a code snippet, how I can insert binary data into a table?

    Thnx: ReLuXa from Hungary

    • Nobody/Anonymous

      I've solved my problem...

      • Peter Bromberg

        Peter Bromberg - 2004-10-19

        Well, Thanks for telling everyone all about your discovery! The only way I have been successful with images is to convert to Base64 string going in, and back out.

        • Nobody/Anonymous

          it seems that transcation is invalid when insert blob.

          if you insert blob item a/b/c/d/e/f... into a colonm, every row of the colonm will be a.

      • Alexander Gavrilov

        Here is the snippet:

        IDbCommand cmd = connection.CreateCommand();
        cmd.CommandText = "CREATE TABLE Tbl (t BLOB)";

        byte[] someValues = {0x01,0x02};
        cmd.CommandText = "INSERT INTO Tbl (t) VALUES (@t)";
        IDbDataParameter p = cmd.CreateParameter();
        p.DbType = DbType.Binary;
        p.Value = someValues;


Log in to post a comment.