DOC: Corrections to Visual Basic .NET Samples in "Sample .NET Data Provider" Documentation (317963)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework) 1.0
  • Microsoft Visual Basic .NET (2002)

This article was previously published under Q317963

SUMMARY

When you try to compile the Visual Basic .NET sample code that is included in the Sample .NET Data Provider topic in the Microsoft .NET Framework Software Development Kit (SDK) documentation, you receive the following error messages:
TemplateCommand.vb(6) : error BC30149: 'DotNetDataProviderTemplate.TemplateCommand' must implement 'Overridable Overloads Function CreateParameter() As IDbDataParameter' for interface 'System.Data.IDbCommand'.

-and-

TemplateCommand.vb(6) : error BC30149: 'DotNetDataProviderTemplate.TemplateCommand' must implement 'Overridable Overloads Sub Dispose()' for interface 'System.IDisposable'.

TemplateCommand.vb(136) : error BC30401: 'CreateParameter' cannot implement 'CreateParameter' because there is no matching function on interface 'IDbCommand'.

-and-

Public Function CreateParameter() As IDataParameter Implements IDbCommand.CreateParameter

-and-

TemplateConnection.vb(7) : error BC30149: 'DotNetDataProviderTemplate.TemplateConnection' must implement 'Overridable Overloads Sub Dispose()' for interface 'System.IDisposable'.

-and-

TemplateDataReader.vb(8) : error BC30149: 'DotNetDataProviderTemplate.TemplateDataReader' must implement 'Overridable Overloads Sub Dispose()' for interface 'System.IDisposable'.

-and-

TemplateTransaction.vb(7) : error BC30154: 'DotNetDataProviderTemplate.TemplateTransaction' must implement 'Overridable Overloads ReadOnly Property Connection() As IDbConnection' for interface 'System.Data.IDbTransaction'. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers.

-and-

TemplateTransaction.vb(7) : error BC30149: 'DotNetDataProviderTemplate.TemplateTransaction' must implement 'Overridable Overloads Sub Dispose()' for interface 'System.IDisposable'.

MORE INFORMATION

To resolve these errors, you must modify the code in the Visual Basic .NET samples.

TemplateCommand.vb

  1. Open TemplateCommand.vb. Replace the code in the CreateParameter method with the following code:
        Public Function CreateParameter() As IDbDataParameter Implements IDbCommand.CreateParameter
          Return CType(New TemplateParameter(), IDbDataParameter)
        End Function
    					
  2. Add the following code to TemplateCommand.vb before the end of the class:
        Public Sub Dispose() Implements IDisposable.Dispose
          Me.Dispose(True)
          System.GC.SuppressFinalize(Me)
        End Sub
    
        Private Sub Dispose(disposing As Boolean)
          '
          ' Dispose of the object, and perform any cleanup.
          '
        End Sub
    					
  3. Save and close TemplateCommand.vb.

TemplateDataReader.vb

  1. Open TemplateDataReader.vb. Add the following code before the end of the class:
        Public Sub Dispose() Implements IDisposable.Dispose
          Me.Dispose(True)
          System.GC.SuppressFinalize(Me)
        End Sub
    
        Public Sub Dispose(disposing As Boolean)
          If disposing Then
              Try
                Me.Close()
              Catch e As Exception
                Throw e
              End Try
          End If
        End Sub
    					
  2. Save and close TemplateDataReader.vb.

TemplateTransaction.vb

  1. Open TemplateTransaction.vb. Add the following code before the end of the class:
        Public ReadOnly Property Connection As IDbConnection Implements IDbTransaction.Connection
          '
          ' Set and retrieve the connection for the current transaction.
          '
    
          Get
            Return Me.Connection
          End Get
        End Property
    
        Public Sub Dispose() Implements IDisposable.Dispose
            Me.Dispose(True)
            System.GC.SuppressFinalize(Me)
        End Sub
    
        Private Sub Dispose(disposing As Boolean)
          If disposing Then
              If (Not Me.Connection Is Nothing)
                ' Implicitly roll back if the transaction still valid.
                Me.Rollback()
              End If
          End If
        End Sub
    					
  2. Save and close TemplateTransaction.vb.

TemplateConnection.vb

  1. Open TemplateConnection.vb. Add the following code before the end of the class:
        Public Sub Dispose() Implements IDisposable.Dispose
          Me.Dispose(True)
          System.GC.SuppressFinalize(Me)
        End Sub
    
        Private Sub Dispose(disposing As Boolean)
          '
          ' Dispose of the object, and perform any cleanup.
          '
    
          If m_state = ConnectionState.Open Then Me.Close()
        End Sub
    					
  2. Save and close TemplateConnection.vb.
  3. Compile and run the sample.

Modification Type:MinorLast Reviewed:1/22/2004
Keywords:kbdocerr kbnofix kbprb KB317963 kbAudDeveloper