Microsoft KB Archive/172403: Difference between revisions

From BetaArchive Wiki
m (Text replacement - """ to """)
m (Text replacement - "&" to "&")
 
Line 162: Line 162:
</div>
</div>
<p>To avoid this error in ADOVB, comment out or remove the following line of code, in the Click event procedure for cmdAccess in the code window for frmADOVB:</p>
<p>To avoid this error in ADOVB, comment out or remove the following line of code, in the Click event procedure for cmdAccess in the code window for frmADOVB:</p>
<pre class="codesample">List1.AddItem vbTab &amp; "OriginalValue= " &amp; rs1.Fields(i).OriginalValue
<pre class="codesample">List1.AddItem vbTab & "OriginalValue= " & rs1.Fields(i).OriginalValue
                     </pre></li></ul>
                     </pre></li></ul>



Latest revision as of 11:29, 21 July 2020

Article ID: 172403

Article Last Modified on 3/2/2005



APPLIES TO

  • Microsoft ActiveX Data Objects 1.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition



This article was previously published under Q172403

For a Microsoft Visual Basic .NET version of this article, see 308656.

SUMMARY

Adovb.exe is a self-extracting compressed file containing sample code that demonstrates how to use ActiveX Data Objects (ADO) within Visual Basic.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services


Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

FileName Size Date
AdoDemo.mdb 332KB 7/28/97
AdoVB 18KB 8/5/97
AdoVB.vbp 1KB 8/5/97
AdoVbEx 6KB 7/28/97

What Adovb Demonstrates

Adovb demonstrates proper use of output and return parameters (for SQL Server), and opening a parameterized recordset for both a Microsoft Access and SQL Server data sources. Also included is a generic template for error handling with ADO code:

   Private Sub cmdTemplate_Click()
      Dim Conn1 As adodb.Connection

      On Error GoTo VbError   ' Trap (non-ADO) error/exceptions

      ' Create Connection Object (using early binding)
      Set Conn1 = new ADODB.Connection

      On Error GoTo AdoError  ' Trap any error/exception

      Conn1.ConnectionString = AccessConnect
      Conn1.Open

      '----------------------
      ' YOUR CODE GOES HERE!
      '----------------------

      ' Successful Shutdown
      Conn1.Close

   Done:
      ' Miscellaneous (graceful) Cleanup
      On Error Resume Next

      Set Conn1 = Nothing

      Exit Sub

   ' ADO Error/Exception Handler
   AdoError:
      ' Save Error Information!
      ErrNumber = Err.Number
      ErrSource = Err.Source
      ErrDescription = Err.Description

      AdoErrorEx List1, Conn1

   ' Non-ADO Native error/exception handler
   VbError:
      VbErrorEx List1, ErrNumber, ErrSource, ErrDescription
      GoTo Done

   End Sub
                

NOTES:

  • When using ADOVB with ADO 2.0 or later, you should remove the Reference to Microsoft OLE DB ActiveX Data Objects 1.0, and set a Reference to the latest version of Microsoft ActiveX Data Objects available.
  • When using ADO 2.0 or later, referencing the OriginalValue property of an ADO Field object will give the following error, if the LockType of the ADO Recordset is Read Only:

    Run-time error '3251': The operation requested by the application is not supported by the provider.

    To avoid this error in ADOVB, comment out or remove the following line of code, in the Click event procedure for cmdAccess in the code window for frmADOVB:

    List1.AddItem vbTab & "OriginalValue= " & rs1.Fields(i).OriginalValue
                        


REFERENCES

About the ADO* Series of Samples

This is one of several identical samples implemented using ADO within various products, as listed below. The advantage is that these articles have an identical interface/functionality, demonstrating both the similarities and differences in using ADO with different languages / mechanisms:

172403 FILE: Adovb.exe Demonstrates How to Use ADO with Visual Basic


220152 Sample: ADOVC1 Simple ADO/VC++ Application


185033 FILE: Adoacc.exe Demonstrates Using ADO with Access 97



Additional query words: AdoVB

Keywords: kbinfo kbdownload kbstoredproc kbdatabase kbfile kbsample kbcode KB172403