Error connecting to the database - only for mobile browsers and forms applications

I have an odd problem and I’m hoping someone has some thoughts on what might be going on. I am seeing this issue in multiple forms applications that were created in earlier versions of SC, but the error is present under both SC 9.6 and SC 9.7.

The issue is that when I use a mobile browser (or Chrome/Edge in developer mode with device emulation turned on and set to a mobile browser) then my forms applications return errors like:

"An error occurred while connecting to the database: Connection attempt failed: SQLSTATE[28000]: [Microsoft][ODBC Driver 17 for SQL server][SQL Server]Login Failed for user ‘username’.

or with a MYSQL connection:

“An error occurred while connecting to the database: Connection attempt failed: SQLSTATE[HY000] [1045] Access denied for user ‘root@localhost’ (using password: YES)”

On my Android phone, if I select “Request desktop site” in the browser then the form loads properly. Other apps (grids, controls, charts) seem to load normally when using the mobile browser or mobile emulation.

Why is changing the browser to mobile causing the database connection issue?

I’m using IIS as the web server if that matters.

1 Like

I have the same issue but slightly different (reverse?) circumstances:

  • MySQL database
  • accessing a master-detail form via a mobile browser displays the form well rendered for mobile but adds “display desktop version” at the bottom
  • clicking the display desktop version brings up this error in the detail form only
  • clicking the show SQL reveals somehow the variables passed between master and detail disappear, so the sql needed to load it cannot execute.

(You seem to get the error when you switch from desktop to mobile?)

I’m at a loss as to why a switch between versions causes it. I resort to hiding the “display desktop version” link altogether but would be happy to know a fix also.

1 Like

I played with this a little more today and found that it isn’t just affecting forms applications, it is affecting control applications as well.

After some experimentation it appears that the issue arises when a control or form has a select field (or double select, maybe anything with a lookup) that uses a different database connection than the one defined for the main application.

So:

  • Form “A” which uses database connection conn_mysql_A and has two fields… field_1 and field_2
  • Set field_2 as a Select type
  • Set the field lookup to automatic
  • Set the database connection for the lookup to conn_mysql_B
  • Create an automatic lookup query that runs against database B
  • Load the form in a desktop browser. This should work.
  • Reload the form using the developer mode (Chrome or Edge) to emulate a mobile browser. This throws the database connection error for me.

Can anyone else test this and see if you can duplicate the issue? I am using SC 9.7 and IIS as my web server with PHP 7.3, but I also tested under Apache with PHP 7.0 and got the same results.

2 Likes

This one was a bit of an adventure to solve. I decided to upgrade my Scriptcase installation from PHP 7.0 to PHP 7.3 in the middle of trying to figure this out, so I’m still not sure I understand everything that was happening across the two versions, but I now can see where there is an issue in the latest SC 9.7 / PHP 7.3 installation.

TLDR; the database connection mapping that is done during deployment, from the DEV database connection to the PROD database connection, doesn’t work for mobile pages. If the DEV connection name isn’t exactly the same as the PROD connection name, then the mobile browser version of the application will throw a database connection error.


Longer explanation:

The issue is with “Select” type fields where the automatic lookup specifies a database connection. So where there is a connection selected in the box I have highlighted below:

image

If the selected database connection doesn’t exist with exactly the same name in the production environment, the mobile view doesn’t work. There is a step in the deployment process where you map the DEV connections to the PROD connections, but it appears that the mapping doesn’t work for the mobile pages.

So during deployment I map the dev connections to the prod connections as follows:

     DEV                 PROD
conn_mysql_1_dev ----> conn_mysql_1

When I used conn_mysql_1_dev for the field2 automatic lookup, the desktop view would work, but the mobile browser would throw a database connection error.

When I created a new connection in DEV where the name exactly matched the production name then the mobile pages work.

    DEV               PROD
conn_mysql_1 -----> conn_mysql_1

I am going to report this to Scriptcase as a bug. Hopefully they can duplicate the issue.

1 Like

Can you share a screenshot of this? Never seen it.

1 Like

@scriptcaser It is one of the steps when using Advanced Deployment:

image

1 Like