找不到表0。 [英] Cannot find table 0.

查看:460
本文介绍了找不到表0。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我正在将xml转换为数据集,但在服务器上我遇到了无法找到表0的问题,因为我在本地计算机上检查了它没有在这里复制它,但在生产中我会得到这个错误有时但不是连续的。我正在编写将xml转换为数据集的行。请帮助解决问题。



Hello All,

I am converting xml to dataset but on server I am getting issues of can not find table 0 as I have checked it on local machine but didn't replicate it on here but on production I will get this error some times but not continuously. I am writing the lines that will convert xml to dataset. Please help to resolve the issue.

String xmlString = loaddata;

                       System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(xmlString));
                       reader.Read();

                       System.Data.DataSet dsData = new System.Data.DataSet();
                       dsData.ReadXml(reader, System.Data.XmlReadMode.Auto);
                       reader.Close();







谢谢,

Amit Mehan



我的尝试:



我试过以下代码也没有解决我的问题..






Thanks,
Amit Mehan

What I have tried:

I have tried the below code as well but doesn't solve my issue..

if (dsData.Tables.Count > 0)
                       {
                           if (dsData.Tables[0] == null)
                           {
                               reader = new System.Xml.XmlTextReader(new System.IO.StringReader(xmlString));
                               reader.Read();

                               dsData = new System.Data.DataSet();
                               dsData.ReadXml(reader, System.Data.XmlReadMode.Auto);
                               reader.Close();
                           }
                       }

推荐答案

你好,

这是清除你的 DataSet 是空的还是null。因此它无法找到任何表。像这样修改你的代码

Hello ,
This is clear that your DataSet is blank or null .Hence it can not find any table . Modify your code like this way
if(dsData !=null && dsData.Tables.Count > 0)
{
//do other stuff
}



谢谢


Thanks


这篇关于找不到表0。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆