注册 登录
编程论坛 VB.NET论坛

关于使用数据窗体向导遇到的问题

hemingsheng 发布于 2008-03-21 22:56, 1146 次点击
我在窗体代码编辑器里定义的如下两个过程
Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Function fill_students() As DataSet1
        Dim ds As New DataSet1
        Me.SqlConnection1.Open()
        Try
            Me.SqlDataAdapter1.Fill(ds, "students")
        Catch excep_fill As System.Exception
            MsgBox("程序出錯,錯誤原因是:" & excep_fill.Message, MsgBoxStyle.Exclamation)
        End Try
        Me.SqlConnection1.Close()
        Return ds
    End Function

    Private Sub update_students(ByVal ds As DataSet1)
        Me.SqlConnection1.Open()
        Dim row_update As DataSet
        Dim row_insert As DataSet
        Dim row_delete As DataSet
        Dim row_unchange As DataSet
        row_update = ds.GetChanges(DataRowState.Modified)
        row_insert = ds.GetChanges(DataRowState.Added)
        row_delete = ds.GetChanges(DataRowState.Detached)
        row_unchange = ds.GetChanges(DataRowState.Unchanged)
        Try
            If ds.HasChanges(DataRowState.Added) Then
                Me.SqlDataAdapter1.Update(row_insert)
            End If
            If ds.HasChanges(DataRowState.Modified) Then
                Me.SqlDataAdapter1.Update(row_update)
            End If
            If ds.HasChanges(DataRowState.Deleted) Then
                Me.SqlDataAdapter1.Update(row_delete)
            End If
            If ds.HasChanges(DataRowState.Unchanged) Then
                Me.SqlDataAdapter1.Update(row_unchange)
            End If
        Catch excep_update As System.Exception
            MsgBox("程序出錯,錯誤原因是:" & excep_update.Message, MsgBoxStyle.Exclamation)
            MsgBox(excep_update.Source)
        End Try
        Me.SqlConnection1.Close()
    End Sub

但是在数据窗体向导的选择加载和更新数据的方法那个步骤下找不到这两个过程请问是怎么回事??
2 回复
#2
hemingsheng2008-03-22 14:16
各位大虾  小弟在线等啊  拜托了。。。。
#3
hemingsheng2008-03-22 15:05
晕了  自己弄明白了
不能是private sub 而要public sub...
1