IBM® Informix® Client Software Development Kit, Version 4.10

Retrieve data into a DataSet

You can use an IfxDataAdapter object to retrieve database information into a System.Data.DataSet object for further processing.

The following example creates a System.Data.DataSet and populates it with the first and last names from the customer table. Then, to show that it is populated, it outputs the System.Data.DataSet to the console in the form of XML.

For the details about the IfxDataAdapter object, see IfxDataAdapter class. For more information about data sets see your .NET or ADO documentation.

try 
{
    // Open a connection
    IfxConnection conn = 
        new IfxConnection(
        "Host=myhost;Service=1541;Server=myifxserver;Database=stores_demo;"
        + "User ID=mylogin;password=mypassword"
        );
    conn.Open();

    IfxDataAdapter da = new IfxDataAdapter(
        "SELECT fname, lname FROM customer",
        conn );
    System.Data.DataSet ds = new System.Data.DataSet("Names");

    //Fill the DataSet
    da.Fill(ds);

    //The DataSet is ready to use.
    //This example outputs the DataSet to the Console as XML
    //just to show that it is populated.
    ds.WriteXml(Console.Out);
    Console.ReadLine(); //Wait for a Return

    // Close the connection
    conn.Close();
}
catch(IfxException e) 
{
    Console.WriteLine(e.ToString());
    Console.ReadLine(); //Wait for a Return
}


Examples exchange | Troubleshooting

To find the PDF, see Publications for the IBM Informix 12.10 family of products.
For the release notes, documentation notes, and/or machine notes, see the Release Notes page.