| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:这代码哪错了怎么改求解答
只看楼主 加入收藏
yanahi775
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-12-9
收藏
 问题点数:0 回复次数:0 
这代码哪错了怎么改求解答
Public Class CategorySalesData
    'declare class level variables
    Private aDataSet As ConancoolDataSet
    Private CategoriesTableAdapter As ConancoolDataSetTableAdapters.CategoriesTableAdapter
    Private Category_Sales_for_1995TableAdapter As ConancoolDataSetTableAdapters.Category_Sales_for_1995TableAdapter

    'constructor
    Sub New()
        'instantiate dataset and table adapter objects
        aDataSet = New ConancoolDataSet
        CategoriesTableAdapter = New ConancoolDataSetTableAdapters.CategoriesTableAdapter
        Category_Sales_for_1995TableAdapter = New ConancoolDataSetTableAdapters.Category_Sales_for_1995TableAdapter
    End Sub

    'function to fill and return  dataset
    Public Function getData() As ConancoolDataSet
        'fill dataset
        CategoriesTableAdapter.Fill(aDataSet.Categories)
        Category_Sales_for_1995TableAdapter.Fill(aDataSet.Category_Sales_for_1995)
        Return aDataSet
    End Function

    'procedure to update database
    Public Sub updateDatabase(ByVal aDataSet As ConancoolDataSet)
        Try
            ' Update child Deletes.
            If aDataSet.Category_Sales_for_1995.GetChanges(DataRowState.Deleted) IsNot Nothing Then
                'Get changes for the deleted child rows only.
                Dim Category_Sales_for_1995DeleteDataTable As DataTable
                Category_Sales_for_1995DeleteDataTable = aDataSet.Category_Sales_for_1995.GetChanges(DataRowState.Deleted)
                Category_Sales_for_1995TableAdapter.Update(Category_Sales_for_1995DeleteDataTable)
            End If
            ' Update all parent row Adds, Deletes, and Changes.
            If aDataSet.Categories.GetChanges() IsNot Nothing Then
                CategoriesTableAdapter.Update(aDataSet.Categories)
            End If
            ' Update child Adds and Edits.
            If aDataSet.Category_Sales_for_1995.GetChanges(DataRowState.Added + DataRowState.Modified) IsNot Nothing Then
                'Get changes for the added and edited child rows only.
                Dim Category_Sales_for_1995AddDataTable As DataTable
                Category_Sales_for_1995AddDataTable = aDataSet.Category_Sales_for_1995.GetChanges(DataRowState.Added + DataRowState.Modified)
                Category_Sales_for_1995TableAdapter.Update(Category_Sales_for_1995AddDataTable)
            End If
            aDataSet.AcceptChanges()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

End Class



我用的是VB语言,下滑线的是显示出错的地方,可是我是按照书上打的,一模一样就不知道怎么错了。求各位解答
搜索更多相关主题的帖子: class objects 
2011-12-11 21:35
快速回复:这代码哪错了怎么改求解答
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056306 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved