none
Need an example of updating a column value (column type is SQL Server bit) using a ADO.Net DataSet RRS feed

  • Question

  • Apologies if this is sitting in some newbie FAQ but...

     

    I have a table that I'm trying update using a DataSet.  I am doing fine with types like varchar(x).  However, I can't seem to find an example dealing with the SQL bit type.

     

    I'm expecting to be able to do something like this:

     

     

    Code Snippet

    foreach (DataRow dr in dsStatus_Table.Tables[0].Rows)

    {

    string simdir = prefix + (string)dr["directory"];

    SqlContext.Pipe.Send("Simulation " + (string)dr["directory"]);

    SqlContext.Pipe.Send(" Type: " + (string)dr["status"]);

    if ((string)dr["status"] == null)

    {

    dr["status"] = get_simtype(simdir); // this change gets happily saved

    }

    if (dr["siminfo_file"] is DBNull)

    {

    dr["siminfo_file"] = false; // this is ignored

    }

    }

    sda.Update(dsStatus_Table, "dbo.mytable");

     

     

    but the changes to the siminfo_file column never get written back (the status column change works fine).

     

    Thanks,

     

    --Andrew

     

     

    Wednesday, July 30, 2008 11:59 PM

All replies

  • Original problem solved (silly mistake in my update function).  However, I'd still like to see an example that shows best practice for dealing with null values.

     

    Thanks!

     

    --Andrew

    Thursday, July 31, 2008 12:06 AM