DatabaseConnection_SetConnectionStringForSession not function

DatabaseConnection_SetConnectionStringForSession not function

  

Hi,

I have three databases (SQL Server)  with same table called 'Product'. Now I try to test the DatabaseConnection_SetConnectionStringForSession function.

In Integration Studio, I have already put '[Product]' to Table or View Name field in extension. Then I publish it to Service Center.

To test with the connection, I try to use it in Preparation without any SQL connection before. Inside it I try to use the DatabaseConnection_SetConnectionStringForSession with the following parameter:


connectionName: "OUTS-DYNAMIC-DATABASE-TESTING"
connectionString: "Uid=admin;Pwd=Password;Server=XXX.XXX.XXX.XXX;Database=OUTS-TEST003;"


However I cannot get the data from TEST003. Thus anything that I was missing?


Thanks,

Benedict

Hello Benedict,

You're saying you are not using anything before the DatabaseConnection_SetConnectionStringForSession is called? It is the first thing in the preparation?

If not, try it. If so, let's try to remove some questions to see what is happening.

1. What's the error message. There is any? If not, what is happening exactly?
2. Are you able to get data from any of the other databases?
3. I assume yes, but are you module using the latest version of the extension (did you refreshed the references)?
4. The user's defined in each connection have access rights to the tables you're trying to access?
5. The schemes in each database are exactly the same? 

Cheers.


Hi,

did you read this:

https://success.outsystems.com/Documentation/10/Reference/OutSystems_APIs/PlatformRuntime_API#DatabaseConnection_SetConnectionStringForSession

especially:

If there is a single query that uses the Database Connection with the old database before this action is executed, the switch to the new database will not happen until the end of the current request. Only in a next request the database switch becomes effective.


Eduardo Jauch wrote:

Hello Benedict,

You're saying you are not using anything before the DatabaseConnection_SetConnectionStringForSession is called? It is the first thing in the preparation?

If not, try it. If so, let's try to remove some questions to see what is happening.

1. What's the error message. There is any? If not, what is happening exactly?
2. Are you able to get data from any of the other databases?
3. I assume yes, but are you module using the latest version of the extension (did you refreshed the references)?
4. The user's defined in each connection have access rights to the tables you're trying to access?
5. The schemes in each database are exactly the same? 

Cheers.


Hi Eduardo,

Thank you for your reply. Let me provide more information.

Before I try this API, I have create a page that fetch data in the same databases. The Product tables are having same schemes. Below shows the preparation for the connection process. This can achieve what I want but this method is a little bit stupid... Especially if I need to add more databases later on, I need to put much effort to add the logic.


Then I try the DatabaseConnection_SetConnectionStringForSession API starting with simple logic, just connect to one of the databases to see if the connection is successful or not.

 


No error message is appeared, and seems it cannot connect to the database.


Benedict

Benedict,

No error message in the Error logs in Service Center? Why do you think it is a connection issue? If it was the case, you should have a log of the error. Add a database error handler to the action shwoing the error in a message to be sure.

Also, are you showing the data in the page (in a table records)? If not, probably the system will just ignore the aggregate as it will detect it is not being used... (I think).

Cheers.

Eduardo Jauch wrote:

Benedict,

No error message in the Error logs in Service Center? Why do you think it is a connection issue? If it was the case, you should have a log of the error. Add a database error handler to the action shwoing the error in a message to be sure.

Also, are you showing the data in the page (in a table records)? If not, probably the system will just ignore the aggregate as it will detect it is not being used... (I think).

Cheers.

Hi Eduardo,


My location is in Hong Kong so I maybe late for reply...


No error message was found. I add some breakpoints inside the flow of second image, The List in GetDynamicProducts keeps empty. So at this point I think there are two possibilities:
1. Database connection error, but until now it doesn't have any logs to support this point.
2. The flow only provides the connection to switch database, but no place for putting and displaying the data.

Focus on point 2, anything that I need to do after make/switch the database connection? Maybe an aggregate is not enough?


Benedict