开发者

I am accessing a MySQL database using the .NET connector and getting the error "Guid should contain 32 digits and 4 dashes"

开发者 https://www.devze.com 2022-12-14 16:01 出处:网络
I have a .NET application which allows users to access various databases by providing a connection string and a provider.

I have a .NET application which allows users to access various databases by providing a connection string and a provider.

One of the databases which users want to access is a MySQL database (not mine so I can't change it) where the primary keys are all stored as GUIDs.

My application can access records in various tables in that database when using the MySQL ODBC 3.51 Driver.

But using exactly the same code (taking into account that ODBC needs a ? in place of a parameter name whereas the .NET connector needs the "@name" syntax), and attempting to read the same records in the same tables but this time with the MySQL .NET Connector (V6.1.3 as well as v6.2.2), then I get the error "Guid should contain 32 digits with 4 dashes ...".

Is there something wrong with the .NET Connector, or is there something I 开发者_运维技巧need to specify somewhere to make it work?


Well, after scouting around a bit, I thought I would see if MySQL had released a later version of the .NET Connector than I had. I found https://dev.mysql.com/downloads/connector/net/. That says something about the error that I was receiving, and speaks about an option "old guids=true" in the connection string (it doesn't say when and how you should use this, but that it didn't work properly in version 6.1.3).

I tried putting "oldguids=true" in my connection string, and then my generic application worked.


I had the same problem, but it was caused by a Stored Procedure in which I was declaring a variable of type Char(36) and MySql (I'm guessing the Connector) was interpreting that as a GUID. So by changing its size to 37 (or whatever) it worked.


server=localhost;user=root;password=abc123;database=test;old guids=true;

Watch out old guids=true part.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号