简体   繁体   English

C#数据集错误

[英]C# Dataset error

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?) 找不到类型或名称空间名称“公司”(您是否缺少using指令或程序集引用?)

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))

Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter refers to a class, not a variable, hence the assignment fails. Company.Project.DataProvider.MyDataSetTableAdapters.MyTableAdapter引用一个类,而不是变量,因此分配失败。

Try: 尝试:

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

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM