2

I am currently writing an output file that is generated using some Mapbasic Code into a MS SQL Database:

Dim SQL_output_tablename as String

SQL_output_tablename = """dbo"""&"."&"""ClientOutput_" 
   + CurrentDay + "_" + CurrentMonth + "_" + CurrentYear 
   + "_" + CurrentHour + "h" + CurrentMinute + "m"""

Commit Table Client As "C:\Program Files\MapInfo\Mapinfo_SQL\Client.TAB"
   **Type ODBC Connection 1** 
   Table SQL_output_tablename Type SQLServerSpatial 
   Geometry ConvertDateTime ON Interactive

The issue is that I am unsure of how to reference the ODBC connection using the name instead of the assigned Index. Mapinfo gives the connections an Index, 1 being assigned to the first ODBC connection opened etc.

Is it possible to write the code differently and specify the ODBC connection (The name and not the index) to be used when writing to a DB?

1

You could control that connection number via variable. For example you should define your connection like

dim i_hdbc as integer

' - connection string to a specific MS SQL database for example     
i_hdbc = Server_Connect("ODBC",
    "DSN="+s_DSN+                   
    ";DATABASE="+s_BAZA+
    ";UID="+s_USER+
    ";PWD="+s_PASS+
    ";MARS_Connection=Yes"+
    ";")  

Open table "C:\MapInfo\USA" 
Commit Table USA as "c:\temp\as\USA" 
   Type ODBC Connection i_hdbc Table "USA"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.