Microsoft KB Archive/317963

= DOC: Corrections to Visual Basic .NET Samples in &quot;Sample .NET Data Provider&quot; Documentation =

Article ID: 317963

Article Last Modified on 1/22/2004

-

APPLIES TO


 * Microsoft ADO.NET 1.0
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



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
  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   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  Save and close TemplateCommand.vb.

TemplateDataReader.vb
  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  Save and close TemplateDataReader.vb.</ol>

TemplateTransaction.vb
  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 </li> Save and close TemplateTransaction.vb.</li></ol>

TemplateConnection.vb
  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 </li> Save and close TemplateConnection.vb.</li> Compile and run the sample.</li></ol>

Additional query words: Implementing a .NET Data Provider TemplateCommand TemplateDataReader TemplateTransaction TemplateConnection

Keywords: kbnofix kbprb kbdocerr KB317963

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.