ID: Q129901
The information in this article applies to:
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.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
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.
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
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:
ARTICLE-ID: Q163435
TITLE : VBA: Programming Resources for Visual Basic for
Applications
Additional query words: XL5 XL7 XL97 disabled dimmed
Keywords : kbprg kbdta kbdtacode ODBCGen KbVBA
Version : WINDOWS:5.0,5.0c,7.0,7.0a,97; MACINTOSH:5.0,5.0a,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto
Last Reviewed: May 17, 1999