开发者

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

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.

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜