Ado| Index ADOX is said to be very powerful, but I did not feel it, because I wrote a lot of programs under ASP, can not run. For some reason, here's a program that can get a unique index. Maybe some friends will do some general-purpose programs, that is, no matter how the data structure changes, the program is unchanged, from data entry, modify, delete, to data retrieval. All modules are completely independent of the structure of the database table. This makes it necessary to obtain a unique index for the table. Because the record that is currently being deleted is marked by a unique index. If a table is a regular table, there should be at least one unique index, because the table should have a primary key, and the primary key is the unique index. I try to use Adox.key to get the primary key of the table, error! Don't know what the reason. Also, I try to use the PrimaryKey of index to obtain whether the index is a primary key, but no matter what index, returns True. Helpless, only by judging whether it is unique. It turns out that this method is really good. Only the final program returns a string of N (n>=1) fields separated by commas (,). Most unique indexes, however, are made up of one field. We can also judge the types of these fields as needed. Fangins This is not the only way to get a unique index. Open a pattern query through the OpenSchema method of the data connection, or you can get a table of the main keyword, detailed method see [? here?].
ConnStr = "provider=msdaora.1; User id=liujincai;password=ljc1001;data Source=hp1 "
Set AdoX = Server.CreateObject ("Adox.catalog")
Set fld = Server.CreateObject ("Adox.column")
Set Tt=server. CreateObject ("Adox.table")
Adox.activeconnection = ConnStr
Set Tt=adox. Tables ("Tb_house_main")
Set Kk=server. CreateObject ("Adox.key")
Set Idx=server. CreateObject ("Adox.index")
Response.Write "Table:" & TT. Name
Response.Write "< table border=1>
< tbody>
< tr bgcolor= #e0d0c0 >
< Td>column name</TD>
< Td>column type</TD>
< td>columnsize</td></tr> "
For I=0 to TT. Columns.count-1
Set fld = TT. Columns (i)
Ltype = fld. Type
Lsize = fld. DefinedSize
Response.Write "< TR bgcolor= #f0e0d0 >< td>" &fld. Name & "</td>"
Response.Write Ltype
Response.Write "</td>< td>"
Response.Write lsize
Response.Write "</td></tr>"
Next
Response.Write "</tbody></table>"
Cols= ""
For I=0 to TT. Indexes.count-1
Set IDX=TT. Indexes (i)
If Idx. Unique=true Then
For j=0 to IDX. Columns.count-1
Cols=cols & "," & IDX. Columns (j). Name
Next
Exit For
End If
Next
If cols<> "" Then
Cols=mid (Cols,2,len (cols)-1)
Response.Write "Can uniquely Mark fields:" &cols