Microsoft KB Archive/129901

From BetaArchive Wiki

Article ID: 129901

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0 Standard Edition



This article was previously published under Q129901


SUMMARY

When you use the SQLGetSchema function with a value of 3 for the TypeNum argument, information will be returned only for certain open database connectivity (ODBC) databases.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. SQLGetSchema, a function included in the XLODBC.XLA add-in, is used to return information about the structure of the data source on a particular connection. TypeNum, one of the arguments of SQLGetSchema, is used to specify the type of information you want returned about the data source. The syntax for this function is:

   SQLGetSchema(ConnectionNum, TypeNum, QualifierText)
                

Using a value of 3 for the TypeNum argument returns a list of owners in a database on the current connection. Owner lists can be generated only with the following ODBC database drivers:

Microsoft SQL Server, version 4.2x and later Oracle, versions 6.0 and 7.0 Sybase SQL Server (contact Sybase Corporation technical support for a list of supported versions)


To find out whether or not a data source can support a list of database owners, connect to the data source with Microsoft Query. In the Add Table dialog box, there is an Owners drop-down list box. If this drop-down list box is unavailable, then the driver does not support the use of Owners.

Below is an example using the SQLGetSchema function to return a list of database owners.

Sample Visual Basic Procedure

  Sub GetOwnerList()
      ' Open a communication channel to the database.
      chan = SQLOpen("DSN=My SQL Server Database")

      ' Get Owner list for the MyDB database.
      OwnerList = SQLGetSchema(chan, 3, "MyDB")

      ' Loop through the owner list and display the values.
      For Each OwnerName In OwnerList
         MsgBox OwnerName
      Next

      ' Close the communication channel.
      SQLClose chan
   End Sub
                

REFERENCES

For more information about SQLGetSchema, click the Search button in Visual Basic Reference Help and type:

sqlgetschema


For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

163435 VBA: Programming Resources for Visual Basic for Applications



Additional query words: XL5 XL7 XL97 disabled dimmed XL

Keywords: kbdtacode kbhowto kbprogramming KB129901