为什么总是提示:Class shuser必须为接口:system.iDisposable实现"SUB Dispose" 呢?,
Public Class ShUser
Implements IDisposable 该句为什么总是提示:Class shuser必须为接口:system.iDisposable实现"SUB Dispose" 呢?,我下面已经有了呀.
Protected dsCommand As SqlDataAdapter
Protected Acn As SqlConnection
Private loadCommand As SqlCommand
Private insertCommand As SqlCommand
Private updateCommand As SqlCommand
Private deleteCommand As SqlCommand
Private db As Database
#Region "初始化"
Public Sub New()
db = DatabaseFactory.CreateDatabase()
dsCommand = New SqlDataAdapter()
Try
Acn = New SqlHelper().GetConn()
Acn.Open()
Catch e As SqlException
Throw e
End Try
dsCommand.TableMappings.Add("Table", ShUserData.SHUSER_TABLE)
End Sub
Public Sub Dispose()
Dispose(True)
GC.SuppressFinalize(True)
End Sub
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not disposing Then
Return
End If
If dsCommand IsNot Nothing Then
If dsCommand.SelectCommand IsNot Nothing Then
If dsCommand.SelectCommand.Connection IsNot Nothing Then
dsCommand.SelectCommand.Connection.Dispose()
End If
dsCommand.SelectCommand.Dispose()
End If
If dsCommand.InsertCommand IsNot Nothing Then
If dsCommand.InsertCommand.Connection IsNot Nothing Then
dsCommand.InsertCommand.Connection.Dispose()
End If
dsCommand.InsertCommand.Dispose()
End If
If dsCommand.UpdateCommand IsNot Nothing Then
If dsCommand.UpdateCommand.Connection IsNot Nothing Then
dsCommand.UpdateCommand.Connection.Dispose()
End If
dsCommand.UpdateCommand.Dispose()
End If
If dsCommand.DeleteCommand IsNot Nothing Then
If dsCommand.DeleteCommand.Connection IsNot Nothing Then
dsCommand.DeleteCommand.Connection.Dispose()
End If
dsCommand.DeleteCommand.Dispose()
End If
dsCommand.Dispose()
dsCommand = Nothing
End If
End Sub
#End Region
#Region "执行查询语句(内部使用)"
''' <summary>
''' 执行查询语句
''' </summary>
''' <param name="commandText">命令行SQL</param>
''' <returns>ShUserData</returns>
Private Function GetTableData(ByVal commandText As String) As ShUserData
If dsCommand Is Nothing Then
Throw New System.ObjectDisposedException([GetType]().FullName)
End If
Dim data As New ShUserData()
Try
Dim command As New SqlCommand(commandText, Acn)
dsCommand.SelectCommand = command
dsCommand.Fill(data)
Catch e As Exception
Throw e
End Try
Return data
End Function