Why am I getting an error when connecting to MySql in C# .Net Core 3

LukeBurke_PremierEPOS

I have just updated from MySql.Data.MySqlClient .Net Core Class Library version 8.0.21 to 8.0.22 and it seems to have caused errors for some of my SQL queries. I am not getting the following error:

"Non-negative number required. (Parameter 'count')"

When I am trying to run the following code:

DataTable dt = new DataTable();
try {
    using (MySqlConnection con = new MySqlConnection(ConnectionString)) {
        using (MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM shortcuts WHERE user = @id", con)) {
            da.SelectCommand.Parameters.AddWithValue("@id", userId);
            da.Fill(dt);
        }
    }
} catch (Exception ex) {
    Console.WriteLine(ex.Message);
    dt = null;
}

I cannot see what the error is complaining about and I only have 8 records in the "shortcuts" table that I am trying to retrieve data from. Since I haven't changed any of my code and it was working before I updated my NuGet package, I am assuming that it is an issue with the latest build. I did, however, try to downgrade back to the version I was on and there was no luck.

I don't know if this is the right place to report errors or get information but I would appreciate any help. Here are some things that I have tried:

  • Downgrading back to version 8.0.21
  • Restarting the MySql service (I am using XAMPP and my local machine at the moment)
  • Adding "da.SelectCommand.Parameters.Clear();" at the top of the code to make sure there are no parameters stuck from previous queries, as it will work for other queries but not this one.

Thanks for any assistance you can provide

Bradley Grainger

Are you querying a table that has a CHAR(36) column (i.e., a GUID) containing NULLs? If so, you're encountering bug 101252, a regression introduced in MySql.Data 8.0.22.

You could roll back to 8.0.21, but I would personally recommend switching to MySqlConnector (disclaimer: I'm the lead contributor) as it has better compatibility with .NET Core and fixes many bugs present in MySql.Data.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why am I getting error: "Cannot access disposed object" in .net core 2 with EF and AutoFac?

分類Dev

Why am I getting a 403 error when uploading to S3 from the browser?

分類Dev

Why am I getting an uninitalized heap memory error when using a pointer (C++)?

分類Dev

Why am I getting a CASE error when in Data Studio?

分類Dev

why am i getting this error when reading a .json file?

分類Dev

Why am i getting this error when i am trying to insert a string into a list?

分類Dev

Why am I getting an Inferred Latch Error?

分類Dev

Why am I getting an error with Find in VBA?

分類Dev

Why am I getting unexpected string error?

分類Dev

Why am I getting an "ArrayIndexOutOfBoundsException" error?

分類Dev

Why am I getting an undefined error when using ngIf and ViewChild together

分類Dev

no function clause matching in Access.get/3 - Why am I getting this error?

分類Dev

Why am I getting this error: "error: { expected" in JCreator?

分類Dev

Why am I getting the error "OverflowError: Python int too large to convert to C long" from pandas/matplotlib?

分類Dev

Why am I always getting Segmentation faults when displaying my array in C?

分類Dev

Why am I getting an Error 1309 : Error reading from file..... when attempting to use a .msi generated by InstallShield in VS 2013?

分類Dev

Why am I getting a "Task was destroyed but it is pending" error in Python asyncio?

分類Dev

Why I am getting "getuid was not declared in that scope" error?

分類Dev

Why am I getting the error "Identifier ... has already been declared"?

分類Dev

Why am I getting a "Cannot find module 'jsonLogic'" error?

分類Dev

Why am I getting "Error while validating constraint None"?

分類Dev

Why am I getting an error while using group by with a left join?

分類Dev

Why am i getting error for .format? JAVA FILES

分類Dev

why am i getting this error in simple angularjs program?

分類Dev

Why am I getting duplicated data when scraping?

分類Dev

I am getting a Fatal error when trying to go to a page

分類Dev

Why am I getting an undefined?

分類Dev

Why am I getting this KeyError?

分類Dev

I am getting error when I am trying to get video links of YouTube playlist using Paffy

Related 関連記事

  1. 1

    Why am I getting error: "Cannot access disposed object" in .net core 2 with EF and AutoFac?

  2. 2

    Why am I getting a 403 error when uploading to S3 from the browser?

  3. 3

    Why am I getting an uninitalized heap memory error when using a pointer (C++)?

  4. 4

    Why am I getting a CASE error when in Data Studio?

  5. 5

    why am i getting this error when reading a .json file?

  6. 6

    Why am i getting this error when i am trying to insert a string into a list?

  7. 7

    Why am I getting an Inferred Latch Error?

  8. 8

    Why am I getting an error with Find in VBA?

  9. 9

    Why am I getting unexpected string error?

  10. 10

    Why am I getting an "ArrayIndexOutOfBoundsException" error?

  11. 11

    Why am I getting an undefined error when using ngIf and ViewChild together

  12. 12

    no function clause matching in Access.get/3 - Why am I getting this error?

  13. 13

    Why am I getting this error: "error: { expected" in JCreator?

  14. 14

    Why am I getting the error "OverflowError: Python int too large to convert to C long" from pandas/matplotlib?

  15. 15

    Why am I always getting Segmentation faults when displaying my array in C?

  16. 16

    Why am I getting an Error 1309 : Error reading from file..... when attempting to use a .msi generated by InstallShield in VS 2013?

  17. 17

    Why am I getting a "Task was destroyed but it is pending" error in Python asyncio?

  18. 18

    Why I am getting "getuid was not declared in that scope" error?

  19. 19

    Why am I getting the error "Identifier ... has already been declared"?

  20. 20

    Why am I getting a "Cannot find module 'jsonLogic'" error?

  21. 21

    Why am I getting "Error while validating constraint None"?

  22. 22

    Why am I getting an error while using group by with a left join?

  23. 23

    Why am i getting error for .format? JAVA FILES

  24. 24

    why am i getting this error in simple angularjs program?

  25. 25

    Why am I getting duplicated data when scraping?

  26. 26

    I am getting a Fatal error when trying to go to a page

  27. 27

    Why am I getting an undefined?

  28. 28

    Why am I getting this KeyError?

  29. 29

    I am getting error when I am trying to get video links of YouTube playlist using Paffy

ホットタグ

アーカイブ