MySQL link string problem

Source: Internet
Author: User

<add key= "Connstringmysql" value= "SERVER=XXX.XXX.XXX.XXX;DATABASE=YOURDATABASE;UID=XXX;PWD=XXX;POOLING=FALSE; Charset=utf8; Treat Tiny as Boolean=false; Convert Zero datetime=false "/>

1.pooling: The value of this key is set to true and any newly created connection will be added to the connection pool when the program is closed, the connection is taken from the connection pool the next time you try to open the same connection, and if the connection string is the same, it is considered the same connection. If the connection string is not the same, it is considered a different connection.
2.charset: This one should understand that setting character encoding
3.Treat Tiny as Boolean: If set to true, the tinyint type in MySQL will be converted to the bit type in MS Server, but sometimes we do not want this to be converted, so this can be configured according to their own needs
4.Convert Zero Datetime: This problem is encountered today, and when this property is not set, if the Datetime column in the MySQL database is null,. NET throws the following exception when converting: unable to convert MySQL Date/time value to System.DateTime at MySql.Data.Types.MySqlDateTime.GetDateTime () This is because the default minimum date for. NET and MySQL mismatch, resulting in a conversion error, the solution is the above connection string (set convert Zero datetime=true)

protected static string connectionString = "server=127.0.0.1; User Id=root; Password=root; Persist Security info=true;database=lianxi0727; Allow Zero datetime=false; ";
Allow Zero datetime=true should be false, otherwise the returned date will be MySql.Data.Types.MySqlDateTime type, not datatime

Database 2018-02-01 00:00:00 If true, the conversion fails

MySQL link string problem

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.