0

This would work in vb.net 4.6:

Dim da as New MySqlDataAdapter(New MysqlCommand("","server=MyServerAddress;uid=MyUser;pwd=MyPW;database=MyInitialCatalog"))

da.Fill(MyDataSet.MyTable)

In NET 6 I get an error. I don't know anything to do with it:

'Windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Arg_ParamName_Name

I don't know where to encode what. I have never seen this error, probably because I don't know a lot about DataBase Connections

I don't specify an 'encoding name' anywhere. Can you help me with what I need to do here?

EDIT: I could find the same error occurs at

Dim test = New MySqlConnection("server=MyServerAddress;uid=MyUser;pwd=MyPW;database=MyInitialCatalog")
test.Open
  • The following may be helpful: https://stackoverflow.com/a/71540398/10024425 in showing how to connect to a MySQL database. In the post, just replace: `using (MySqlDataReader dr = cmd.ExecuteReader())...` with `using (MySqlDataAdapter da = new MySqlDataAdapter(cmd)) ...` Obviously, you'll need to also convert it to VB.NET. – Tu deschizi eu inchid Jul 13 '22 at 14:32
  • So the only helpful difference there is that its done in Framework 4.8. So as I said it is working in Framework. But I try to make it work in NET 6 –  Jul 14 '22 at 06:26
  • I've tested both NuGet package: [MySql.Data](https://www.nuget.org/packages/MySql.Data/) and [MySqlConnector](https://www.nuget.org/packages/MySqlConnector/). using .NET 6, and both work. See [here](https://mysqlconnector.net/overview/installing/) and [here](https://mysqlconnector.net/connection-options/) for more information on using MySqlConnector. – Tu deschizi eu inchid Jul 14 '22 at 14:49
  • The following may (or may not) be helpful: https://stackoverflow.com/questions/1049728/how-do-i-see-what-character-set-a-mysql-database-table-column-is – Tu deschizi eu inchid Jul 14 '22 at 14:49
  • unfortunately I dont see any of your links addressing the issue. The exception thrown is a ArgumentExpception. MySqlConnection.Open method does not have such an exception in the documentation, so I think it has to do with something else. I dont know what the difference between SqlConnection and MySqlConnection really is, but since SqlConnection works fine for me, I guess this encoding thing will be somehow different for both. But I dont know anything about Encoding. How can I change the Encoding? –  Jul 15 '22 at 18:34
  • _I dont know what the difference between SqlConnection and MySqlConnection really is_: I'm not sure what you mean by this statement. Nothing that you've posted mentions `SqlConnection`, nor does any URL that I've posted. I recommend that you create a new project and follow the step-by-step instructions from the first URL that I posted to ensure that you can successfully connect to your MySQL database. [SqlConnection Class](https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection?view=netframework-4.8) states: _Represents a connection to a SQL Server database_ – Tu deschizi eu inchid Jul 15 '22 at 19:06
  • It is not working. But I wrote that already, there is no encoding addressed –  Jul 25 '22 at 10:18

0 Answers0