IArticleDatabaseFactory.GetArticleDatabase Method
Function GetArticleDatabase( _
ByVal filePath As String, _
Optional ByVal getExclusiveLock As Boolean = False _
) As IArticleDatabase
This language is not supported or no code example is available.
Parameters
- filePath
- string
Required. The full database path of the article database whose instance is to be retrieved. For SQL Server database it is the connection string, for SQLite database it is the full path to the file. See remarks for more details.
- getExclusiveLock
- bool
Optional. The default value is false. If set to true, then the file gets an exclusive lock.
Return Value
IArticleDatabaseThe article database loaded from the file or database.
To check whether a database comes from an SQLServer, you can test whether the connection string starts with "ProviderRemoteDatabaseServer".
To connect to SQL server databases, the filePath parameter should have the following format:
ProviderRemoteDatabaseServer;<DATABASE_PATH>\<DATABASE_NAME>
You can get the full database path string using the IQdvEnvironment.GetDatabasePath method, as you would do with a local database:
DbPath = context.QdvManager.Environment.GetDatabasePath(PathNumber)
The database name may look like "MyDatabase.qdb"
The resulting string may then look as follows:
ProviderRemoteDatabaseServer;128.1.2.3;QDV_databases;DBTESTS;4xrODLGqs+EHmfJm6YHRYQ==;False\MyDatabase.qdb
Then open the database as usual:
ArticleDb = context.QdvManager.ArticleDatabaseFactory.GetArticleDatabase("ProviderRemoteDatabaseServer;128.1.2.3;QDV_databases;DBTESTS;4xrODLGqs+EHmfJm6YHRYQ==;False\MyDatabase.qdb")
Note
If you call this code from an external application and not from a macro, then you need to put the following lines in your App.config file:
<system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> <remove invariant="QuickDevis.Server" /> <add name="Service Data Provider" invariant="QuickDevis.Server" description=".Net Framework Data Provider for Web Services" type="QuickDevis.Server.DbProviderFactoryService, QuickDevis.Server" /> </DbProviderFactories> </system.data> <appSettings> <!-- Which provider? --> <add key="ProviderRemoteDatabaseServer" value="System.Data.SqlClient" /> <add key="ProviderLocalDatabaseServer" value="System.Data.SQLite" /> </appSettings>