我的代码有问题。
我在Visual Studio 2010中使用了ASP.NET。

当我从数据库检索数据到Web服务中的数据表时,某些列给我一个空的字符串数据。这导致检索和显示的XML出现问题。我尝试放入Replace ("","")代替\0\0\0。这可以解决这个问题。但是现在的问题是,原始数据仍然显示在XML中。原始数据是带有\0\0的数据。替换前,XML字段为<VNDPNO></VNDPNO>,替换后为<VNDPNO />

我的问题是,如何隐藏原始数据。
我打电话时不想要原始数据
它会继续显示在Web浏览器的<diffgr:before>中。

我的源代码是:

public DataTable GetItmSupDtls(string companycode, string itemCode,
                               string itemMajor, string itemMinor)
{
    DataTable dsItmSupDtls;
    //DataSet dsItmSupDtls = new DataSet();
    IDBManager dbManager = new DBManager(DataProvider.SqlServer);
    dbManager.ConnectionString = _connString;
    try
    {
        dbManager.Open();
        dbManager.CreateParameters(4);
        dbManager.AddParameters(0, "@COYCDE", (object)companycode);
        dbManager.AddParameters(1, "@ITMCDE", (object)itemCode);
        dbManager.AddParameters(2, "@ITMMAJ", (object)itemMajor);
        dbManager.AddParameters(3, "@ITMMIN", (object)itemMinor);
        dsItmSupDtls = dbManager.ExecuteDataSet(
            CommandType.StoredProcedure,
            Utilities.DatabaseName("DBPurchase") + ".dbo.ITMSUPINFO_STKBALENQUIRY"
        ).Tables[0];
    }

    catch (Exception ex)
    {
        throw ex;
    }

    finally
    {
        dbManager.Dispose();
    }

    DataTable result = dsItmSupDtls.Clone();

    foreach (DataRow dtRow in dsItmSupDtls.Rows)
    {
        dtRow["VNDPNO"] =
            dtRow["VNDPNO"].ToString().Replace("\0", ""); //"A"; //
        result.ImportRow(dtRow);
    }
    return result;
}


请给我一些评论和建议。

非常感谢..

最佳答案

您的信息传输方式是通过diffgram。我认为如果使用ImportRow而不是InsertRow,历史将随之而来。由于InsertRow包含很多行可能会更昂贵,因此您可能只想在值包含null时使用ImportRow。

10-06 05:21
查看更多