Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取相同的错误System.IndexOutOfRangeException:在过去两天中找不到表0_C#_Asp.net - Fatal编程技术网

C# 获取相同的错误System.IndexOutOfRangeException:在过去两天中找不到表0

C# 获取相同的错误System.IndexOutOfRangeException:在过去两天中找不到表0,c#,asp.net,C#,Asp.net,我正在尝试从此类在gridview中填充数据,但获取错误时找不到表0。我还附上了错误的图像 这是类名“class1”中的代码 检查数据集是否有3个表 if(ds.Tables.Count >0) { GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); GridView2.DataSource = ds.Tables[1]; GridView2.DataBind(); GridView

我正在尝试从此类在gridview中填充数据,但获取错误时找不到表0。我还附上了错误的图像

这是类名“class1”中的代码


检查数据集是否有3个表

if(ds.Tables.Count >0)
{
    GridView1.DataSource = ds.Tables[0];
    GridView1.DataBind();
    GridView2.DataSource = ds.Tables[1]; 
    GridView2.DataBind();
    GridView3.DataSource = ds.Tables[2];
    GridView3.DataBind();
}

检查数据集是否有3个表

if(ds.Tables.Count >0)
{
    GridView1.DataSource = ds.Tables[0];
    GridView1.DataBind();
    GridView2.DataSource = ds.Tables[1]; 
    GridView2.DataBind();
    GridView3.DataSource = ds.Tables[2];
    GridView3.DataBind();
}

在上设置断点

对于(int j=0;j 在手表上检查dt_开关_record.Rows.Count的值


如果是0,那么这就是问题所在,数据集ds.Tables.Add(dt_running)没有填充,因为dt_running为null,如果查询返回零行,则ds.Tables[0]将永远不存在。检查数据库/表和连接字符串。

在上设置断点

对于(int j=0;j 在手表上检查dt_开关_record.Rows.Count的值


如果是0,那么这就是问题所在,数据集ds.Tables.Add(dt_running)没有填充,因为dt_running为null,如果查询返回零行,则ds.Tables[0]将永远不存在。检查数据库/表和连接字符串。

我猜您可能没有更改数据层、架构层或某个存储过程。请检查并让我知道它是否有效


我犯了一个类似的错误,然后我意识到我没有编辑架构层。

我猜您可能没有更改数据层、架构层或其中一个存储过程。请检查并让我知道它是否有效


我犯了一个类似的错误,然后我意识到我没有编辑模式层。

哪里有例外?@Guy Line 28:DataSet ds=ad.get_rates();第29行:第30行:GridView1.DataSource=ds.Tables[0];//这里我得到了错误行31:GridView1.DataBind();第32行:GridView2.DataSource=ds.Tables[1];//这里我得到了一个错误,我认为SQL查询返回0行,因此ds.Tables[0]中没有数据。打开调试器,看看哪里有异常?@Guy第28行:DataSet ds=ad.get_rates();第29行:第30行:GridView1.DataSource=ds.Tables[0];//这里我得到了错误行31:GridView1.DataBind();第32行:GridView2.DataSource=ds.Tables[1];//这里我得到了一个错误,我认为SQL查询返回0行,因此ds.Tables[0]中没有数据。a访问调试器并查看是的,它有3个表,即…“网关打开”“在”“上运行客户端调用”“运行其他客户端调用ONY它有3个表,即…“网关打开”“在”“上运行客户端调用”“运行其他客户端调用”ON@ErikOppedijk brother for(int j=0;jif(ds.Tables.Count >0) { GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); GridView2.DataSource = ds.Tables[1]; GridView2.DataBind(); GridView3.DataSource = ds.Tables[2]; GridView3.DataBind(); }