Putting Array Object Into Database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • EMiller

    #1

    Putting Array Object Into Database

    Hello,
    I am encountering a development challenge here that seems
    to be stumping me.

    I am developing a C#/.NET application using an MSDE
    database. There is a particular field in a table that I
    need to accept a two-dimensional array of integers. When
    creating the database, I chose the SQL_Variant datatype
    for this column to which I will be writing the array.

    In my code, I create the array, fill in the data, and when
    it comes to write time, I do the following:

    ASB2003.OrderDa taSet.Order_Inf orRow NewOrderRow;
    NewOrderRow.Ser vices = SaveArgs.m_COrd erData.Services Array;
    orderDataSet1.O rder_Infor.Rows .Add(NewOrderRo w);

    Where ASB2003 is the application namespace and
    orderDataSet1 is the active dataset for the table in
    question. So here I create a new row, and copy to it the
    services array. I then add the new row to the order
    dataset. All is well, and when I look at the order dataset
    in Debug, the new row is added to the dataset,the array is
    nicely nestled where it should be in its list of items,
    and I can see all the lovely data has persisted.

    But, when it comes to updating the database using this
    function, where OrderDataAdapte r is the data adapter for
    the order table:

    OrderDataAdapte r.Update(orderD ataSet1);

    an exception occurs, and it is

    "System.Data.Ol eDb.OleDbExcept ion: Unspecified error"

    Why is this happening? The row I created was happy with
    everything, why would the update not take it?

    Does the SQL_Variant not accept the type of data
    (System.Array) that was contained in the row for that
    column?

    Any ideas you may have about putting an array into the
    database will be met with much gratitude!

    Thank you one and all!
    Eric








Working...