|
|
|
|
|
Dicas
|
|
Visual Basic (Banco de Dados)
|
|
|
Título da Dica: Usuários conectados e schema do banco (catalogo)
|
|
|
|
Postada em 24/8/2003 por Ð@®l@n
Precisando saber quem esta conectado ao seu banco de dados??? Vamos usar a ADO para pode exibir quem esta conectado ao seu banco de dados Access.
Private Sub Command1_Click() Dim cnn As New ADODB.Connection Dim rs As New ADODB.Recordset cnn.CursorLocation = adUseClient cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=c:\dados.mdb;"
' Para abrir um esquema(Estrutura) do recordset vamos usar o método OPenSchema Set rs = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:="{947bb102-5d43-11d1-bdbf-00c04fb92675}")
List1.AddItem "COMPUTER_NAME LOGIN_NAME CONNECTED" List1.AddItem "___________" For i = 1 To rs.RecordCount List1.AddItem rs!COMPUTER_NAME List1.AddItem rs!LOGIN_NAME List1.AddItem rs!CONNECTED List1.AddItem "___________" rs.MoveNext Next End Sub
---------------------
Você pode saber outras informações sobre a tabela e o banco também, abaixo uma pequena lista sobre tipos de consulta. Para saber mais procure no Help do VB (OpenSchema)
Set recordset = connection.OpenSchema (QueryType, Criteria, SchemaID)
Onde :
QueryType - indica o tipo de Schema(estrutura) que a consulta irá retornar. Para ver os valores desta constante clique aqui - Constantes QueryType. Criteria . Um vetor de consultas com restrições para cada opção de QueryType. Veja os valores clicando aqui - Constantes Criteria. SchemaID - Um identificador único para o schema do provedor. Este parâmetro somente é necessário se definirmos QueryType como sendo adSchemaProviderSpecific.
Valores QueryType Valores Criteria
adSchemaAsserts CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaCatalogs CATALOG_NAME
adSchemaCharacterSets CHARACTER_SET_CATALOG CHARACTER_SET_SCHEMA CHARACTER_SET_NAME
adSchemaCheckConstraints CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaCollations COLLATION_CATALOG COLLATION_SCHEMA COLLATION_NAME
adSchemaColumnDomainUsage DOMAIN_CATALOG DOMAIN_SCHEMA DOMAIN_NAME COLUMN_NAME
adSchemaColumnPrivileges TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME GRANTOR GRANTEE
adSchemaColumns TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaConstraintColumnUsage TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaConstraintTableUsage TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
adSchemaForeignKeys PK_TABLE_CATALOG PK_TABLE_SCHEMA PK_TABLE_NAME FK_TABLE_CATALOG FK_TABLE_SCHEMA FK_TABLE_NAME
adSchemaIndexes TABLE_CATALOG TABLE_SCHEMA INDEX_NAME TYPE TABLE_NAME
adSchemaKeyColumnUsage CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME
adSchemaPrimaryKeys PK_TABLE_CATALOG PK_TABLE_SCHEMA PK_TABLE_NAME
adSchemaProcedureColumns PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME COLUMN_NAME
adSchemaProcedureParameters PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME PARAMTER_NAME
adSchemaProcedures PROCEDURE_CATALOG PROCEDURE_SCHEMA PROCEDURE_NAME PARAMTER_TYPE
adSchemaProviderSpecific See Remarks
adSchemaProviderTypes DATA_TYPE BEST_MATCH
adSchemaReferentialConstraints CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME
adSchemaSchemata CATALOG_NAME SCHEMA_NAME SCHEMA_OWNER
adSchemaSQLLanguages <none>
adSchemaStatistics TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
adSchemaTableConstraints CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
adSchemaTablePrivileges TABLE_CATALOG TABLE_SCHEMA TABLE_NAME GRANTOR GRANTEE
adSchemaTables TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
adSchemaTranslations TRANSLATION_CATALOG TRANSLATION_SCHEMA TRANSLATION_NAME
adSchemaUsagePrivileges OBJECT_CATALOG OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE GRANTOR GRANTEE
adSchemaViewColumnUsage VIEW_CATALOG VIEW_SCHEMA VIEW_NAME
adSchemaViewTableUsage VIEW_CATALOG VIEW_SCHEMA VIEW_NAME
adSchemaViews TABLE_CATALOG TABLE_SCHEMA TABLE_NAME
|
|
|
|
|