C# 数据集错误

发布于 2024-11-06 14:07:06 字数 1796 浏览 1 评论 0原文

我有以下代码:

namespace Company.Project.DataProvider
{    
    partial class MyDataSet
    {
        partial class MyDataTable
        {
        }
    }
}

namespace Company.Project.DataProvider.MyDataSetTableAdapters
{
    public partial class MyTableAdapter
    {
        public int CommandTimeout
        {
            set
            {
                for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1))
                {
                    if ((this.CommandCollection[i] != null))
                    {
                        this.CommandCollection[i].CommandTimeout = value;
                    }
                }
            }
        }
    }

    protected void ObjectDataSource1_ObjectCreating
        (object sender, ObjectDataSourceEventArgs e)
    {
        Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter =  
            (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
              e.ObjectInstance;
        // Set command timeout to 2 minutes
        adapter.CommandTimeout = 120;
    }
}

当我运行上面的代码时,我收到以下错误:

类型或命名空间名称“Company” 找不到(您是否缺少 使用指令或程序集 参考?)

我的代码有什么问题?


现在,我收到以下错误。

CS1061: 'CariPeriyot.Rapor.TEST_TumRaporlar' does not contain a definition 
for 'CommandCollection' and  no extension method 'CommandCollection' 
accepting a first argument of type 'CariPeriyot.Rapor.TEST_TumRaporlar' 
could be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 7:         set
Line 8:         {
Line 9:           for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1))
Line 10:           {
Line 11:              if ((this.CommandCollection[i] != null))

I have the following code:

namespace Company.Project.DataProvider
{    
    partial class MyDataSet
    {
        partial class MyDataTable
        {
        }
    }
}

namespace Company.Project.DataProvider.MyDataSetTableAdapters
{
    public partial class MyTableAdapter
    {
        public int CommandTimeout
        {
            set
            {
                for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1))
                {
                    if ((this.CommandCollection[i] != null))
                    {
                        this.CommandCollection[i].CommandTimeout = value;
                    }
                }
            }
        }
    }

    protected void ObjectDataSource1_ObjectCreating
        (object sender, ObjectDataSourceEventArgs e)
    {
        Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter =  
            (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
              e.ObjectInstance;
        // Set command timeout to 2 minutes
        adapter.CommandTimeout = 120;
    }
}

When I run above code, I receive the following error:

The type or namespace name 'Company'
could not be found (are you missing a
using directive or an assembly
reference?)

What is wrong in my code?


Now that,I receive the following error.

CS1061: 'CariPeriyot.Rapor.TEST_TumRaporlar' does not contain a definition 
for 'CommandCollection' and  no extension method 'CommandCollection' 
accepting a first argument of type 'CariPeriyot.Rapor.TEST_TumRaporlar' 
could be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 7:         set
Line 8:         {
Line 9:           for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1))
Line 10:           {
Line 11:              if ((this.CommandCollection[i] != null))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

So要识趣 2024-11-13 14:07:06

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter 引用一个类,而不是一个变量,因此赋值失败。

尝试:

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter foo = ...

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter refers to a class, not a variable, hence the assignment fails.

Try:

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter foo = ...

兔姬 2024-11-13 14:07:06

将以下代码替换

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter =  
   (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
    e.ObjectInstance;

为:

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter adapter =  
   (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
    e.ObjectInstance;

Replace the following code:

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter =  
   (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
    e.ObjectInstance;

With:

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter adapter =  
   (Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter)
    e.ObjectInstance;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文