C
C#2y ago
Monolith

❔ Error while trying to connect to MySql using MySql .Data

While trying to connect to maria db using mysql.data i get this error:
Unhandled task exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Diagnostics.TraceInternal.get_AppName () [0x0000e] in <e804fc8285a9419784599893ed028695>:0 at System.Diagnostics.TraceInternal.TraceEvent (System.Diagnostics.TraceEventType eventType, System.Int32 id, System.String format, System.Object[] args) [0x0003d] in <e804fc8285a9419784599893ed028695>:0 at System.Diagnostics.Trace.TraceError (System.String message) [0x00000] in <e804fc8285a9419784599893ed028695>:0 at MySql.Data.MySqlClient.MySqlTrace.LogError (System.Int32 id, System.String msg) [0x00026] in <89b4d3936e0b4e49b8d299ddbfe7933d>:0 [ script:LLL_CORE_CS] at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x0002e] in <89b4d3936e0b4e49b8d299ddbfe7933d>:0 at MySql.Data.MySqlClient.MySqlPool.GetConnection () [0x0001c] in <89b4d3936e0b4e49b8d299ddbfe7933d>:0 at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00245] in <89b4d3936e0b4e49b8d299ddbfe7933d>:0 at TestDB.Class1.DBTESTAsync () [0x0002f] in C:\Users\Maurice\source\repos\TestDB\TestDB\Class1.cs:22 Recreating Infos: Builder: dotnet on Debian 10.13 Code: using System; using System.Threading.Tasks; using MySql.Data.MySqlClient; namespace TEST.Server { public class ServerMain { public static void DBTEST() { var connString = "server=localhost;user=NAME; database=NAME;port=3306;password=***"; MySqlConnection conn = new MySqlConnection(connString); try { Console.WriteLine("Connecting to MySQL..."); conn.Open(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } public ServerMain() { DBTEST(); } } }
4 Replies
Monolith
Monolith2y ago
bump
arju_s
arju_s2y ago
You probably have checked the connection string correctly, but If you would like to double check the connection string format as given here... https://www.connectionstrings.com/mysql/ ! Also, I'm just wondering if the "NAME" is a variable or an actual value because if you're going for the variable you're missing the string interpolation and stuff!
MySQL connection strings - ConnectionStrings.com
Connection strings for MySQL. Connect using MySqlConnection, MySQLDriverCS, SevenObjects MySqlClient, Devarts MySqlConnection, MySQLProv.
Monolith
Monolith2y ago
Thanks for the link, but i tried many variations of the connect string. seems to be allright. really stuck at this point. dont know why the error occurs
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts