Explore mysql. Data. dll

Source: Internet
Author: User
Ado. Net driver for MySQL
MySQL. Data. dll is a driver used by. Net to access the MySQL database. The full ADO. NET data access mode is officially provided by MySQL and multiple versions are available.

The first environment to be used:. net2.0 + mysql5.x + MySQL. Data. dll 1.0.7. It seems very stable and has never been a big problem. As the system is upgraded, try to update MySQL. data. dll version (version 1.07 is not officially available for download. The latest versions are 1.0.10, 5.0.8, and 5.1.4). Exceptions may occur.The timeout period elapsed prior to completion of the operation or the serverIsNot responding

When the business logic and data remain unchanged, I had to worry about exceptions when I changed mysql. Data. dll.

In fact, this problem sometimes occurs in sqlserver. It is recommended that you set the connectiontimeout and commandtimeout durations to solve this problem. MySQL. data. these attributes are also available in DLL, and MySQL is downloaded. data. after reading the DLL source code, it seems that a glimmer of hope has been found. In the source code of version 1.07, connectionstring. CS class has

[Category ( " Connection " )]
[Description ( " Number of seconds to wait for the connection to succeed " )]
[Defaultvalue ( 15 )]
Public   Int Connectiontimeout
{
Get {ReturnGetint ("Connect timeout");}
}

Read-only attribute. The default value is 15 seconds. It can be set in the connection string.
In the command. CS class

[Category ( " Misc " )]
[Description ( " Time to wait for command to execute " )]
Public   Int Commandtimeout
{
// Todo: support this
Get {Return 0;}
Set {If(Value! = 0)Throw NewNotsupportedexception ();}
}

The default value is 0, indicating no time limit? Guess. If the value is not 0, an exception is thrown. That is to say, the value can only be 0, that is, the attribute is read-only? The value cannot be changed.

Let's take a look at the new version. In the source code 5.0.8, The mysqlconnectionstringbuilder. CS class contains

[Category ( " Connection " )]
[Displayname ( " Connect timeout " )]
[Description ( " The length of time (in seconds) to wait for a connection "   +
" To the server before terminating the attempt and generating an error. " )]
[Defaultvalue ( 15 )]
[Refreshproperties (refreshproperties. All)]
Public   Uint Connectiontimeout
{
Get   {ReturnConnectiontimeout ;}
Set  
{
Setvalue ("Connect timeout", Value );
Connectiontimeout=Value;
}
}

The attribute can be read and written. The default value is 15 seconds.
In the command. CS class

[Category ( " Misc " )]
[Description ( " Time to wait for command to execute " )]
[Defaultvalue ( 30 )]
Public   Override   Int Commandtimeout
{
Get   {ReturnCommandtimeout ;}
Set   {Commandtimeout=Value ;}
}

The attribute can be read and written. The default value is 30 seconds (these default values are the same as those of sqlserver), which is different from 1.0.7. 1.0.7 is read-only and the value is 0.
I think the timeout exception mentioned above has a lot to do with it. I'm going to test it .......
 
PS: I hope to find some MySQL friends in the garden. If you have any questions, I can discuss them together.CommunityA group was created:. NET + MySql

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.