Clarion 6.3 x MSSQL server (enable MARS?)

Good morning everyone.
I’m migrating an old application written with Clarion 6.3 to access the MSSQL Server 2014 Express. Apparently everything is working except that in some forms is the “Connection is busy with results for another hstmt.” I believe I’m using the wrong driver or I must be making a mistake in the connection string. I ask earnestly someone help me somehow. Thankful.

Yes, you will need to turn on MARS to stop that error from happening. From memory, the command is:

/MULTIPLEACTIVERESULTSETS

in the Driver ‘Options’ line within the Clarion Dictionary - but I am doing this from memory as I am on my Mac and not my Windows Clarion Dev PC at the moment.

Another way is to click the […] button on the driver Options line and tick the box that says ‘Multiple Active Record Sets’ and that will put the correct command in the options line.

Thank you for your reply, but I’ve tried this solution.
Please /MULTIPLEACTIVERESULTSETS is quoted in the Clarion documentation? I did found it.
Regarding the second way, it is necessary to tick “MARS” in all tablets of dct? Or I can tick only FIRST table that will be open in app? As like as a SEND(Mytable,“command”)?

I put those commands in main frame before to open files embed:

WindowDbConnect() ! To Get host, database, user and password.

! string connection: GLO:ConexaoCad = Clip(LOC:Host) & ‘,’ & Clip(LOC:DB) & ‘,’ & Clip(LOC:User) & ‘,’ & Clip(LOC:Pwd)

Versao{Prop:LogonScreen}=False
Send(Versao, ‘/BUSYHANDLING=2’)
Send(Versao, ‘/GATHERATOPEN=TRUE’)
Send(Versao, ‘/MULTIPLEACTIVERESULTSETS=TRUE’)

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

Very important !!! I did not know about this detail… BTW, The devil lives in the details !!!
Thank you. I am going to try today.

I advanced a step forward. Using your tip is now possible to include records without HSTMT error, however, is unfortunately not possible to delete any record in any table even in the simplest without any relationship. The application remains “thinking” and does not exclude nor shows any error message.

I send that parameters before open files on main frame:

Versao{Prop:LogonScreen}=False
Send(Versao, ‘/BUSYHANDLING=2’)
Send(Versao, ‘/GATHERATOPEN=TRUE’)
Send(Versao, ‘/MULTIPLEACTIVERESULTSETS=TRUE’)

You might want to use SQL Profiler to see what statements are being sent to the SQL Server.
I have not seen what you are describing delete records and using MARS. I do still have 1 Clarion 6.3 program running using MARS just like I explained.
There must be something else going on in your program.

Please, what is the version of SQL Server are you using with Clarion 6.3?