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 6053397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:02:08+00:00 2026-05-23T08:02:08+00:00

I’m using Informix and the .NET SDK (C#): Basically, is there any way to

  • 0

I’m using Informix and the .NET SDK (C#):

Basically, is there any way to insert a blob when doing a standard insert sql statement?

INSERT INTO mytable (name, theblob) VALUES ('foo', ? what goes here ?);

Oh, and the data I have is in a form of a byte[] array.

  • 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-23T08:02:09+00:00Added an answer on May 23, 2026 at 8:02 am

    A couple of notes:

    1) You should use parameterized queries

    //Assuming you already have a connection somewhere that is opened.
    
    var sql = "INSERT INTO mytable (name, theblob) VALUES (?, ?);";
    
    using (var command = new IfxCommand(sql, connection))
    {
        command.Parameters.Add(new IfxParameter()).Value = "foo";
        command.Parameters.Add(new IfxParameter()).Value = ifxBlob;
    }
    

    A couple of things to note: Informix has a bug when it comes to the Client SDK 3.5.xC7 (so far). You can easily pass in the byte array during inserts, but you will have a 609 error when doing updates if you pass in a byte[] array. Instead, you must use the IfxBlob object.

    public IfxBlob CreateIfxBlob(byte[] data)
    {
        //Get the connection however you like and make sure it's open...
        //Obviously you should make this method handle exceptions and the such.
    
        IfxBlob blob = connection.GetIfxBlob();
    
        blob.Open(IfxSmartLOBOpenMode.ReadWrite);
        blob.Write(data);
        blob.Close();
    
        return blob;
    }
    

    You have to pass in an IfxBlob instead during update, so you might as well also do it during inserts.

    Also, keep in mind that if you are trying to set null, you will get an error. Instead, if the value is null pass in DBNull.Value.

    public Object AsDBValue(Object value) //Or this Object value if you want it as an extension
    {
        if (value == null)
            return DBNull.Value;
    
        //Other checks
        if (value is Enum)
            return Convert.ChangeType(value, value.GetType().GetEnumUnderlyingType());
    
        //Is Blob?
        if (value is byte[])
            return GetIfxBlob(value as byte[]);
    
        return value;
    }
    

    DO NOT SPECIFY THE TYPE OF PARAMETER

    //These will lead to errors unless you typecast the parameters in the query.
    new IfxParameter { IfxType = IfxType.Blob };
    new IfxParameter { DbType = DbType.Binary };
    

    If you do either of those, you’ll have to do the following:

    • When the Blob value is not null: "INSERT INTO mytable (name, theblob) VALUES (?, ?::blob);";
    • When the Blob value is null: "INSERT INTO mytable (name, theblob) VALUES (?, ?::byte);";

    You can see that it will be a pain in the butt to have different queries because of the type and value. Just don’t specify a DbType or IfxType and let the Informix .NET provider map the correct types for you (even though it can’t map the byte[] array properly on an Update).

    Hope that works out for you, because I went through the same pains trying to figure this out and discovering what I think is a bug in the Informix .NET provider (Ver: 3.5.xC7).

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload

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.