In our current project we are working with 2 databases.
I have both added them in the connections manager and tested their connection, so far so good.
Next I added a table from database A into the DA schema modeler and a stored procedure (as a command) from database B.
These are both showing up correctly, they have both 1 statement with the correct connection filled in in the schema modeler.
In the connections manager you always (?) have a default connection, in my case this was the first database added (‘A’).
When trying out the client, retrieving values from the table in DB A was working as expected.
However, executing the command failed with the message “Could not find stored procedure…” .
When setting the default connection to DB B, the situation is reversed, I cannot get any values from the table in DB A, but can execute the command (the stored procedure) on DB B.
From looking around the table/command should be using the connection defined in the statement, but it seems it is always using the default connection.
Is my thinking correct? Or am I missing something?
I am using Visual Studio 2019 and DA 10.0.0.1463.
Thanks in advance!
To be able to work with Schemas containing objects that use different connections, add the ValidateDatatableAccess, ValidateCommandExecution and BeforeProcessDelta event handlers to your Service with code like:
Thanks for the code, I can see it retrieves and sets the connection property correctly.
However in my client I get the following exception:
{“An exception occurred on the server: Invalid object name ‘IniFile’.”}
With IniFile being the table name.
In this case IniFile is a table from database B, with database A set as default in the connections manager.
When trying:
dataAdapter.GetTable<IniFile>(). …
I got the above exception, I am using the LinqRemoteDataAdapter.
The initial case is working (retrieving from DB A, executing SP on DB B) but when trying to retrieve something from a table from DB B something still goes wrong.
Today we noticed that this code is not building anymore…
We tested versions 10.0.0.1489 and 10.0.0.1495 .
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name ‘DataAbstractServiceValidateDBObjectAccessEventArgs’ could not be found (are you missing a using directive or an assembly reference?)
Sorry for the inconvenience.
There was a major change in this family of events. While we try to maintain backwards compatibility, it was just not possible to provide reliable non-breaking change at these code paths.
That link is a limited access one. Anyway it would not answer your question as it describes changes, not the initial HowTo.
I’ll provide you the answer and code samples in this topic: Dynamically choose DataAbstract connection based on RO call