错误:找不到表0. [英] errore: cannot find table 0.

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

问题描述


我在sql bank中有一张表,但是当我运行程序时,出现一条错误消息:找不到表0.

Hi,
I have one table in sql bank, but when i run my program gives me an error message:cannot find table 0.

for (int i = 0; i <= ds.Tables[0].Rows.Count; i++)
        {
            cmd.CommandText = @"select * from metb";
            da.SelectCommand = cmd;
            da.Fill(ds);
            string fnList = ds.Tables[0].Rows[i]["fn"].ToString();
            Label1.Text += fnList+"/n";
        }

推荐答案

似乎您正在尝试遍历数据集,然后再填充它.
您需要先添加或刷新数据集中的行,然后循环遍历这些行.
像这样的东西

It looks like your are trying to loop through the dataset before you fill it.
You need to add or refresh the rows in dataset first and then loop through the rows.
something like this

cmd.CommandText = @"select * from metb";
            da.SelectCommand = cmd;
            da.Fill(ds);

        if (ds.Tables.Count > 0)
        {
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
            string fnList = ds.Tables[0].Rows[i]["fn"].ToString();
            Label1.Text += fnList+"/n";
         }
        }




您的查询可能没有结果.检查您的数据库查询.还要检查您的表计数是否为非零.如果为零,则返回一些适当的消息.

谢谢
-Amit
Hi,

Your query may result none. Check you database query. Also check if you have nonzero table count. if it is zero then return some appropriate message.

Thanks
-Amit


我有连接错误.
检查您的SQL连接设置.
I thing you have connection error.
Check your sql connection setting.


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

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