C# ServerVersion = “Conn.ServerVersion”引發了“System.InvalidOpe

來源:互聯網
上載者:User

今天複習下C#串連SQL SERVER 資料庫的時候遇到了這個異常。異常不是在try catch 中拋出來的。是在建立SqlConnection對象的時候對象中帶出來的異常。見:
經過仔細檢查,探索資料庫連接字串寫錯了。因為懶惰直接copy某MySql的資料庫連接字串。錯誤的:

string connection = "data source=.;user id=user;password=123";
正確的:
string connection = "server=.;uid=user;pwd=123;";




相關文章

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.