Home All Groups Group Topic Archive Search About

Can't read records with '' in varchar from SQL server into xml

Author
15 Feb 2007 10:43 AM
Solje
I have a table with a column named machinedata of type varchar that
not are allowed to be null. Some of the records are '' because they
not have any data at the moment. I try to read all records from that
table into a dataset using a stored procedure. The code below is a
part of that. The procedure contains a "select * from" statement. The
problem is that the xml file contains the following row for the
machinedata column with ''.
<Table>
........
  <machinedata />
........
</Table>
This row will be ignored when i trying to read i with the
DataSet.ReadXml method. Is there any way around this.

/Thanks

Here is a fragment of the code:
SqlCommand      oExCmd;
DataSet              oDataSet;
SqlDataAdapter   oDa = new SqlDataAdapter();


oExCmd = new SqlCommand( "sp_" + sTableName + "_read", oConn);
oExCmd.CommandType = CommandType.StoredProcedure;
oDa.SelectCommand = oExCmd;
oDataSet = new DataSet();
try
{
   oDa.Fill( oDataSet);
}
.....
oDataSet.WriteXml( "..\\Db\\" + sTableName + ".XML",
XmlWriteMode.WriteSchema);

AddThis Social Bookmark Button