Mysoft.data from entry to proficient series (iii) "Dbsession configuration"

Source: Internet
Author: User
Tags config connectionstrings

Dbsession (Data session Class) is the core of data manipulation, and all database operations are done through it, so you have to instantiate the Dbsession object before writing the database access layer.

Now let's get to know this Dbsession object.

First, the dbsession of the instantiation configuration

Dbsession Two has a way of instantiating it.

1, through the configuration file creation

//指定connectionStrings节的名称来实例化DbSession
public DbSession(string connectName);

This approach is typically used for users who have already configured the connectionstrings section, as follows:

<connectionStrings>
     <add name="DataExample" connectionString="Server=(local);Database=Northwind;Uid=sa;Pwd=sa;"
          providerName="MySoft.Data.SqlServer9.SqlServer9Provider" />
   </connectionStrings>

The above configuration section, if it is a Web project, is specified in web.config, if it is a WinForm project, the specified in app.config

The following providername specifies the drive used by the database link.

The above configuration is only for drivers that are already supported by. NET, such as Access,sqlserver,oracle

Default assembly is MySoft.Data.dll

If Mysql,firebird,sqlite requires additional assembly support, it needs to be configured as follows:

<connectionStrings>
     <add name="DataExample" connectionString="Server=(local);Database=Northwind;Uid=sa;Pwd=sa;"
          providerName="MySoft.Data.MySql.MySqlProvider, MySoft.Data.MySql" />
   </connectionStrings>

ProviderName is written in front of ClassName, followed by AssemblyName.

and need to add related drivers, such as: MYSQL needs to add MySql.Data.dll and MySoft.Data.MySql.dll

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.