SPL3.0 data connection details
SPL3.0 data support capabilities
SPL3.0 has made great improvements in data connection, using a variety of ways to connect to multiple databases, allowing users to have more choices,
Supported databases include SQL Server, Access, Oracle, Other ODBC Connections
Supported connection methods are:
Access SQL Server with System.Data.sqlClient
Access Access and Oracle with System.Data.Oledb
Access SQL Server, Oracle, etc. other ODBC connections with system.data.odbc
Connect Oracle Databases with ODP.NET
Users can freely select these connection methods according to their preferences, which makes SPL3.0 have strong database support capabilities, and how to make these connections in detail.
SPL3.0 connection configuration
SPL3.0 performs great extension in the connection configuration mode, the previous way is to use setting.instance (). DatabaseMapFile = "DatabaseMap configuration file";
This approach is recommended in the SPL, and the connection configuration is quite simple, and the system will automatically load the database connection and the O / R mapping information. However, this way is applicable to the entire system to use the SPL framework. If the SPL is only inserted in the original system, another manual configuration should be used.
Also in large systems, we may encounter multi-book data connections, which is dynamically loaded with database connections, like this way of using it is not appropriate.
To this end, SPL3.0 extends another way of configuring database connections:
Setting.instance (). AppendDatabase (String Name, DatabaseType DatabaseType, String ConnectionString);
parameter:
Name: Index Source Name, this is a concept proposed in the SPL, that is, a data source name determines a data connection, using this data source name to specify the data connection operation in the service.
DatabaseType: This is an enumeration, indicating which way to use data access:
DatabaseType.msqlserver This is the use of SQLClient access SQL Server database
DatabaseType.msAccess This is an Access database using OLEDB
DatabaseType.Oracle This is an Oracle database using OLEDB
DatabaseType.odP This is to access Oracle databases using ODP.NET
DatabaseType.odbc This is an ODBC connection such as an ODBC to access SQL Server, Oracle.
Connectionstring: This refers to the connection string, gives the correct connection string according to different connections.
Such as: setting.instance (). Appenddatabase ("northwind", DatabaseType.odbc, "driver = {SQL Server}; server = localhost; uid = sa; pwd = Both; Database = northwind");
This approach is typically added to the database based on setting.instance (). DatabaseMapFile, because this method is not loaded with O / R mapping information, this method is used for multiple retrograms.
SPL3.0 extends the function of loading O / R mapping separately:
Setting.instance (). LoadClassMap (Server.mAppath (this.m_applicationpath "config / classmap.xml");
If you want to use Appended database connections, you need to load the O / R mapping information when loading data:
Setting.instance (). AppendDatabase (String Name, DatabaseType DatabaseType, String Connectionstring, String Classmappath);
parameter:
The front parameters are the same as the above;
Classmappath: This is the address of the o / r mapping file, is absolute address, such as:
. Setting.Instance () AppendDatabase ( "northwind", DatabaseType.Odbc, "Driver = {SQL Server}; Server = localhost; UID = sa; Pwd = both; Database = Northwind", Server.MapPath (this.m_ApplicationPath "Config /Classmap.xml "));
to sum up
The database supported by SPL3.0 is more, supporting multiple connection methods, and more flexible and diverse in configuration, can accommodate various situations:
1. The SPL Support System is recommended to specify the loaded DatabaseMap file in a DatabaseMapFile. If you support multiple accounts on this basis, you can use the AppendDatabase method to append, or manually load the supplementary O / R mapping information.
2. If the SPL is integrated into the original system, in order to use the data connection of the original system, you can load O / R mapping information simultaneously using AppendDatabase.
SPL3.0 data connection is more than one O / R mapping information loaded than a general data, which is required when using a persistent layer. I hope that these data access features of SPL3.0 can provide you with more choices.
Listen to
2005-1-16