Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. !Note that the code above occasionally needs a tweak depending on the OS involved.
  2. !The ODBC driver naming varies from OS to OS occasionally. I worked around this
  3. !by digging through the registry to find the proper name for the driver so as
  4. !to eliminate the mystery (and the errors) on non-cooperative windows versions.
  5.  
  6. !That code looks like this:
  7.  
  8. qRegistryList QUEUE,PRE(my)
  9. RegValues STRING(40)
  10. END
  11.  
  12. CODE
  13.  
  14. getregsubkeys(REG_LOCAL_MACHINE,'SOFTWARE\WOW6432Node\ODBC\ODBCINST.INI',qRegistryList) !64 bit OS
  15.  
  16. ud.debug('Wow6432 bit - ODBC list: records=' & records(qRegistryList))
  17.  
  18. if records(qRegistryList) = 0
  19. getregsubkeys(REG_LOCAL_MACHINE,'SOFTWARE\ODBC\ODBCINST.INI\ODBC DRIVERS',qRegistryList) !32bit
  20. ud.debug('64 bit - ODBC list: records=' & records(qRegistryList))
  21. end
  22.  
  23. loop intL = 1 to records(qRegistryList)
  24. get(qRegistryList,intL)
  25. if instring('postgresql',lower(qRegistryList.RegValues),1,1) > 0
  26. if instring('unicode',lower(qRegistryList.RegValues),1,1) > 0
  27. GLO:PostgresOwner = 'Driver={{' & clip(qRegistryList.RegValues) |
  28. & '};Server='&CLIP(strServerName)&';Port=5432;Database='&CLIP(strDatabaseName) |
  29. & ';Uid='&CLIP(strUserName)&';Pwd='&CLIP(strUserPwd) & ';'
  30. break
  31. END
  32. end
  33. end
  34.  
  35. ! And finally, because XP. Dont get me started:)
  36.  
  37. strWinVersion = system{prop:WindowsVersion}
  38. ud.debug('system{{prop:WindowsVersion}=' & clip(strWinVersion))
  39. if instring('XP',clip(strWinVersion),1,1) > 0 ! or instring('2012',clip(strWinVersion),1,1) > 0 or instring('Windows 10',clip(strWinVersion),1,1) > 0
  40. GLO:PostgresOwner = 'Driver={{PostgreSQL UNICODE};Server='&CLIP(strServerName)&';Port=5432;Database='&CLIP(strDatabaseName) |
  41. & ';Uid='&CLIP(strUserName)&';Pwd='&CLIP(strUserPwd) & ';'
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement