I am probably missing something silly...but iv'e been trying to figure it out all day so I give up. can anyone spot the error?
App.config
<connectionStrings>
<add name="linkednDb" connectionString="Server=.;Database=linkedin.usernames;Uid=root;Pwd=1234;" providerName="System.Data.SqlClient"/>
Query method :
public void AddUser(string username)
{
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.Connection("linkednDb")))
{
connection.Query<User>($"INSERT INTO usernames (UserName) VALUES ('{username}')");
Console.WriteLine("adding" + username);
}
}
Helper class:
public static class Helper
{
public static string Connection(string name)
{
return ConfigurationManager.ConnectionStrings[name].ConnectionString;
}
}
FORGOT TO ADD error!
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'

For Dapper, this remains something we wouldn't add - it's not worth the safety trade-offs :)Instead of a parameterized query you're executing a dynamically generated string that could easily be invalidO'Reilly? You'd getINSERT INTO usernames (UserName) VALUES ('O'Reilly')and an invalid query errorSystem.Data.SqlClientis the SQL Server client. You can't use it to connect to MySQLmysql, while the code uses a MySQL connection string.