MapInfo Pro

Expand all | Collapse all

Problem with function Server_GetODBCHConn in Windows 10

  • 1.  Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-27-2019 08:39
    I use command

    odbchdbc = Server_GetODBCHConn(ConnectionNumber )

    where odbchdbc , ConnectionNumber are integers and ConnectionNumber is connection number that I got from
      ConnectionNumber = SERVER_CONNECT("ODBC", "DLG=1") (1 for example)

    I got error 471: overflow on this command.
    All this worked fine in all previous version of MapInfo and even in this version (17) but in Windows 7 64 bit only.
    Any help will be appreciated

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-28-2019 02:23
    Hi

    I guess the problem is that the ODBC Connection Handle on 64 bit can be larger than an Integer value.
    You can try to dim your variable "odbchdbc" as a LargeInt type instead or as an IntPtr type.

    Let me check with engineering on the recommend type and also get their feedback on the documentation as it still says Integer for the return type.

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------



  • 3.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-28-2019 04:55
    Thank you for your answer, it really helped and allowed me to advance. Now when I run my MapBasic app all MapInfo crashes more later. I succeed to see the last message in the Message window so I suppose that MapInfo crashes on use of function SQLOwners32 from ODBC32.DLL. So would you please to give me signatures updated of some functions from  ODBC32.DLL
    Below is the list of functions that we use :

    DECLARE FUNCTION SQLAllocStmt32 LIB "ODBC32.DLL" Alias "SQLAllocStmt" (BYVAL hdbc AS INTEGER, hstmt AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLBrowseConnect LIB "ODBC32.DLL" Alias "SQLBrowseConnect" (BYVAL hdbc AS INTEGER, BYVAL szConnStrIn AS STRING, BYVAL cbConnStrIn AS INTEGER, szConnStrOut AS STRING, BYVAL cbConnStrOutMax AS INTEGER, pcbConnStrOut AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLPrepare32 LIB "ODBC32.DLL" Alias "SQLPrepare" (BYVAL hdbc AS INTEGER, BYVAL SQLIn AS STRING, BYVAL SQLInLen AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLExecute32 LIB "ODBC32.DLL" Alias "SQLExecute" (BYVAL SQLIn AS STRING) AS SMALLINT
    DECLARE FUNCTION SQLSetConnectOption LIB "ODBC32.DLL" Alias "SQLSetConnectOption" (BYVAL hdbc AS INTEGER, BYVAL SQLVal1 AS INTEGER, BYVAL SQLVal2 AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLFetch32 LIB "ODBC32.DLL" Alias "SQLFetch" (BYVAL hstmt AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLFreeStmt32 LIB "ODBC32.DLL" Alias "SQLFreeStmt" (BYVAL hdbc AS INTEGER, BYVAL Option AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLGetData32 LIB "ODBC32.DLL" Alias "SQLGetData" (BYVAL hstmt AS INTEGER,BYVAL ColNo AS INTEGER,BYVAL Option AS INTEGER,OutBuf AS STRING,BYVAL OutBufLen AS INTEGER,OutLen AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLTables32 LIB "ODBC32.DLL" Alias "SQLTables" (BYVAL hdbc AS INTEGER, BYVAL TableQualifier AS INTEGER, BYVAL TableQualifierLen AS INTEGER, TableOwner AS STRING, BYVAL TableOwnerLen AS INTEGER,
    TableName AS STRING, BYVAL TableNameLen AS INTEGER, TableType AS STRING, BYVAL TableTypeLen AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLTablesNoOwner32 LIB "ODBC32.DLL" Alias "SQLTables" (BYVAL hdbc AS INTEGER, BYVAL TableQualifier AS INTEGER, BYVAL TableQualifierLen AS INTEGER, BYVAL TableOwner AS INTEGER, BYVAL TableOwnerLen AS INTEGER,
    TableName AS STRING, BYVAL TableNameLen AS INTEGER, TableType AS STRING, BYVAL TableTypeLen AS INTEGER) AS SMALLINT
    DECLARE FUNCTION SQLOwners32 LIB "ODBC32.DLL" Alias "SQLTables" (BYVAL hdbc AS INTEGER, TableQualifier AS STRING, BYVAL TableQualifierLen AS INTEGER, TableOwner AS STRING, BYVAL TableOwnerLen AS INTEGER,
    TableName AS STRING, BYVAL TableNameLen AS INTEGER, TableType AS STRING, BYVAL TableTypeLen AS INTEGER) AS SMALLINT

    DECLARE FUNCTION SQLGetInfo32 LIB "ODBC32.DLL" Alias "SQLGetInfo" ( BYVAL odbchdbc AS INTEGER, BYVAL infoflag AS SMALLINT,
    Database AS STRING,
    BYVAL len AS SMALLINT,
    outlen AS SMALLINT) AS SMALLINT

    The last function I changed to
    DECLARE FUNCTION SQLGetInfo LIB "ODBC32.DLL" Alias "SQLGetInfo" ( BYVAL odbchdbc AS largeint, BYVAL infoflag AS SMALLINT,
    Database AS STRING,
    BYVAL len AS integer,
    outlen AS integer) AS integer


    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 4.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-28-2019 06:39
    Additional question: It is written in MapBasicUserGuide.pdf that there should be Samples\MapBasic\DATABASE Directory in C:\Program Files\MapInfo\MapBasic directory. But there is no such directory. Particularly I need modern version of PickTab.mb file. I have a version of such file but very old and I have problems with some Windows API functions such as  SQLOwners32, SQLFetch32 and some others: MapInfo 17 under Windows 10 crashes when I call these functions. So where   can I get updated versions of these files or may be recommendations to use other methods?

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 5.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Pitney Bowes
    Posted 01-28-2019 07:38
      |   view attached
    In x64, these handles and hstmt, etc., need to be LargeInt.  Attached latest sample code for DATABASE folder in MapBasic

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------

    Attachment(s)

    zip
    DATABASE.zip   133K 1 version


  • 6.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-28-2019 08:05
    Thank you, I'll check it tomorrow.

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 7.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-29-2019 01:20
    Could you please send me file DLSAMP.DEF ?

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 8.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Pitney Bowes
    Posted 01-29-2019 07:45
      |   view attached
    I realized it had some includes outside the Database folder. Sorry.

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------

    Attachment(s)

    zip
    DLSAMP.zip   3K 1 version


  • 9.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-30-2019 13:22
    Thank you

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 10.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Pitney Bowes
    Posted 01-30-2019 14:47
    Edited by Bill Wemple 01-30-2019 14:47
    PickTab.mb has not been updated - shows  invalid contents for table list in dialog after connection is made.  This sample code has not been updated since ~1992 or so.  Perhaps there is a string buffer misalignment going on, but I have not been able to spend much time on updating it as its an obsolete tool. MIODBCAT tool will work with MS Access tables, but not other databases.  It was terribly out of date since all that functionality has been replaced by Easyloader tool in creating Map catalogs .  MISetMBR tool is already installed as a tool in MIPro 17.01 & later.  Hope these samples help.

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------



  • 11.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 01-30-2019 15:58
    Thank you. I got exactly this problem with PickTab you write about. But I thought that it is my fault when I adapted the old code to new environment 64 bit. But now I did not understand what do you recommend to use? You say "Hope these samples help" but what samples? Should I use Easyloader ? I still don't know what is it. I had written some code in MapBasic twenty years ago and now I was asked to adapt working code (not mine) to Windows 10 environment. So any more precise advises would be appreciated. We work with  MS SQL Server tables.

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 12.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Pitney Bowes
    Posted 01-30-2019 19:24
    The *.mb samples and *.def files  I sent earlier were the samples I mentioned that I hope would help.  EasyLoader does  most of the work these old tools used to do like creating a MapInfo Map_Catalog.  I don't know what your MB colde is supposed to do, but these code samples I sent should help you in reworking your old code, especially with connecting to and getting info from SQL Server databases.

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------



  • 13.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Posted 02-05-2019 07:50
    I suppose that the following change should be done in file connect.mb you have sent me:
    Instead of
    ...odbchconn ...AS INTEGER

    should be
    Dim odbchconn as IntPtr

    ------------------------------
    Evgeny Kleiman
    Knowledge Community Shared Account
    ------------------------------



  • 14.  RE: Problem with function Server_GetODBCHConn in Windows 10

    Pitney Bowes
    Posted 02-05-2019 07:58
    Yes, you are correct. Not all samples in the set I sent have been updated for x64.

    ------------------------------
    Bill Wemple
    Principal QA Engineer
    Pitney Bowes
    Troy, NY
    ------------------------------