'A data sheet under a database

zhaozj2021-02-16  59

'' Under the Database 'function name: getdbtabs' parameters: DBCONN ADO connection 'Return Value: Contains a string array of data tables' example: Tabarr = getDBTABS (p_cnn)

Public Function GetDbTabs (ByRef DBconn As ADODB.Connection) As String () Dim RstSchema As ADODB.Recordset Dim strCnn As String Dim ReturnVal () As String Dim ReID As Long On Error Resume Next Set RstSchema = DBconn.OpenSchema (adSchemaTables) Do Until Rstschema.eof if ucase $ (Rstschema.fields ("Table_Type"), 3)) <> "sys" Then Reid = Reid 1 Redim Preserve Returnval (Reid - 1) = Rstschema.fields "Table_Name") '& ":" & RSTSChema! Table_type endiff rstschema.movenext loop rstschema.close set rstschema = Nothing getdbtabs = returnvalend function

'List all table names Private Sub Command2_Click () Dim TableName As String Set rs = conn.OpenSchema (adSchemaTables) Do While Not rs.EOF TableName = rs.Fields ( "TABLE_NAME") List1.AddItem TableName rs.MoveNext LoopEnd Sub

Private subform_load () set conn = new adodb.connection set = new adoDb.recordset conn.connectionstring = "provider = microsoft.jet.Oledb.4.0; data source =" & app.path & "/db.mdb;PERSIST Security info = false "conn.open rs.open" Select * from info ", conn, adopenkeyset, AdlockOptimistic End Sub

Take the ACCESS name.'------------------------------------------- --- Reference. Microsoft ActiveX Data Objects 2.5 LibraryMicrosoft ADO EXT 2.6 for DDL and security '=============================== ====================== Public mcon as adodb.connectionpublic mcat as adox.catalogpublic db_name as stringpublic db_title as string

Private Sub Command1_Click () Dim I As Long Dim TBL As ADOX.Table If Not mCon Is Nothing Then Set mCon = Nothing Set mCon = New ADODB.Connection mCon.Provider = "Microsoft.Jet.OLEDB.4.0" mCon.Mode = adModeRead Mcon.cursorLocation = aduseclient mcon.properties ("Data Source") = "E: /WORKSHAR/CODE.MDB" MCON.Properties ("Jet OLEDB: Database Password") = "" Mcon.Open set mcat = new adox.catalog McAT.ACTIVECONNECTION = MCON for Each Tabl in mcat.tables debug.print Tabl.name Nextend Sub

转载请注明原文地址:https://www.9cbs.com/read-16420.html

New Post(0)