Works in Access, not SQL Server

Results 1 to 2 of 2

Thread: Works in Access, not SQL Server

  1. #1
    Join Date
    Dec 1969

    Default Works in Access, not SQL Server

    I have the following function:<BR><BR>&#060;%<BR>Function ExtractPrimaryKey(strTableName)<BR>sql = "Select * From " & Trim(strTableName)<BR>ors.Open sql, oConn2<BR>set cat = Server.CreateObject("ADOX.Catalog")<BR>set fk = Server.CreateObject("ADOX.Key")<BR>cat.ActiveConne ction = oConn2<BR>set tbl = cat.Tables(Trim(strTableName))<BR> for each key in tbl.Keys<BR> if key.Type = 1 then<BR> return = key.Columns(0).Name<BR> exit for<BR> end if<BR> next<BR>set tbl = nothing<BR>set fk = nothing<BR>set cat = nothing<BR>ors.Close<BR>ExtractPrimaryKey = return<BR>End Function<BR>%&#062;<BR><BR>It is supposed to return the field name that is the primary key. Works fine in access, returns nothing in server. The tables in server do have PK&#039;s. Im having other issues as well....seems no keys (primary or foreign) are coming up in sql server using adox catalog and key. Ant thoughts?

  2. #2
    Join Date
    Dec 1969

    Default RE: Works in Access, not SQL Server

    Don&#039;t use adox. Use the openschema method instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts