Clarion 6.3 x MSSQL server (enable MARS?)

If you are using Clarion 6.x and want to use MARS you have to check which version of the SQL Native Client installed.
Clarion 6.x will only find the SQL 2005 version of the SQL Native Client automatically.
If a newer version of the native client is installed MARS will not work.
You can overcome this limitation by detecting the version of SQL Native Client installed and explicitly adding a Driver option to your connection string.

Here is a method I use to get the driver string value from the registry so it can be added to the connection string.
You can replace the StringClass object with a CSTRING.
This methods tries find each of the SQL native clients versions starting with the latest.

So for your example you can change to this:
GLO:ConexaoCad = Clip(GLO:ConexaoCad ) & ThisWindow.GetSQLNativeClientDriver()

ThisWindow.GetSQLNativeClientDriver PROCEDURE()

DriverString StringClass

  CODE
  DriverString.Assign(GetReg(REG_CLASSES_ROOT,'SQLNCLI11'))
  if not DriverString.Length()
    DriverString.Assign(GetReg(REG_CLASSES_ROOT,'SQLNCLI10'))
  end
  if not DriverString.Length()
    DriverString.Assign(GetReg(REG_CLASSES_ROOT,'SQLNCLI'))
  end
  
  if DriverString.Length()
    DriverString.PreAppend(';Driver=')
  else
    MESSAGE('No SQL Native Client Driver is installed on this machine.|This is necessary for the program to run properly.|Please contact Technical Suppport.','Error',ICON:Hand)
  end
  return DriverString.Get()

Also, you must execute the Send(Versao, ‘/MULTIPLEACTIVERESULTSETS=TRUE’) before any table is opened or connection made to the database.

HTH,
Rick

1 Like