Domain Builder

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Thursday, 13 March 2008

How to get the current DBMS, Database or user through ODBC

Posted on 17:21 by Unknown
These useful informations can be retrieved via direct calls to the ODBC API. This way we don't need DBMS-specific SELECT statement.
External Function Declaration :
FUNCTION integer SQLGetInfo  &
(long hconn, integer infotype, ref string infotypeptr, &
integer bufferlength, ref integer bufferlengthptr) &
LIBRARY "odbc32.dll"

PowerScript:
string ls_dbms, ls_database, ls_user
integer li_length
CONSTANT integer SQL_DBMS_NAME = 17
CONSTANT integer SQL_DATABASE_NAME = 16
CONSTANT integer SQL_USER_NAME = 47
long ll_dbhandle

ls_dbms = space(256)
ls_database = space(256)
ls_user = space(256)
ll_dbhandle = SQLCA.DbHandle()
SQLGetInfo(ll_dbhandle, SQL_DBMS_NAME, ls_dbms, 255, li_length)
SQLGetInfo(ll_dbhandle, SQL_DATABASE_NAME, ls_database, 255, li_length)
SQLGetInfo(ll_dbhandle, SQL_USER_NAME, ls_user, 255, li_length)

MessageBox("Current DBMS" , trim(ls_dbms))
MessageBox("Current DATABASE" , trim(ls_database))
MessageBox("Current USER" , trim(ls_user))
Email ThisBlogThis!Share to XShare to Facebook
Posted in Database | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Categories

  • Database
  • DataWindow
  • PowerScript
  • Win32 API

Blog Archive

  • ▼  2008 (34)
    • ▼  March (14)
      • Retrieve an environment variable
      • Get a list of printers installed
      • List available ODBC datasources
      • How to get the current DBMS, Database or user thro...
      • Sorting Datawindow
      • Hexadecimal to Decimal
      • Julian Date
      • Hiding Application on Windows Taskbar
      • Hiding Desktop and Taskbar
      • Keeping Column into Array
      • Calling Oracle Stored Procs/Functions from PB
      • Re-initializing an Unbounded Array
      • Tracing on Running Application
      • Using Windows Scripting Host
    • ►  February (1)
    • ►  January (19)
Powered by Blogger.

About Me

Unknown
View my complete profile