Connection 5: Get Schema Info

<< Click to Display Table of Contents >>

Navigation:  Examples > Connection >

Connection 5: Get Schema Info

Previous pageReturn to chapter overviewNext page

The sample below shows how you can read schema information from an ADO Connection object

 

FUNCTION Start

 LOCAL strCnn AS STRING

 LOCAL oCOnn AS AdoCOnnection

 LOCAL oRst AS AdoRecordSet

 LOCAL oCons AS Console

 oCOns := Console{}

 AdoDateTimeAsDate(TRUE)

 

 strCnn := "Provider=sqloledb;" + ;

 "Data Source=(local);Initial Catalog=pubs;User Id=sa;Password=; "

 oCOnn := AdoCOnnection{}

 oCOnn:Open(strCnn,NIL,NIL,NIL)

 oCons:Writeline("List of tables")

 oRst := oConn:OpenSchema(AdSchemaTables,{NIL,NIL,NIL,"TABLE"},NIL)

 DO WHILE ! oRst:EOF

 oCOns:WriteLine( oRst:[Collect,1]+" "+ oRst:[Collect,2]+" "+oRst:[Collect,3]+;

         ' '+oRst:[Collect,4])

 oRst:MoveNext()

 ENDDO

 oCons:Writeline("List of views")

 oRst := oConn:OpenSchema(AdSchemaTables,{NIL,NIL,NIL,"VIEW"},NIL)

 DO WHILE ! oRst:EOF

 oCOns:WriteLine( oRst:[Collect,1]+" "+ oRst:[Collect,2]+" "+oRst:[Collect,3]+;

         ' '+oRst:[Collect,4])

 oRst:MoveNext()

 ENDDO

 

 oCOns:Read()