0

I am in the process of creating a basic web interface to access a mysql database. I have XAMPP installed and am now trying to connect the website to the XAMPP server. This is my connection string code:

<connectionStrings>
        <add name="HRDBConnection"
             connectionString="Data Source=localhost;Initial Catalog=HRDatabase;User ID=root;Password="
             providerName="System.Data.SqlClient" />
    </connectionStrings>

From what I can gather my data source should be localhost with the user name and password being the default root and blank respectively.

When I run the code from VS, I get this error on the website where the database tables should show:

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)

I already tried googling this, but all the solutions online I find say I should make the data source = localhost which isn't working. I am not sure if the local host is maybe used for just a SQL server, or if it is for a mysql database through XAMPP. I have XAMPP running the mysql server and I can edit the tables through phpmyadmin.

  • 2
    SQL Server stands for Microsoft SQl Server, which is a different database product from mysql. XAMPP by default comes with mysql or mariadb, not with MS SQL Server. So, what database do you use? – Shadow Jan 18 '23 at 11:31
  • If your plan is to use MySQL or MariaDB, then you must use an appropriate [connection string](https://www.connectionstrings.com/) for those types of DB servers, and you wouldn't use System.Data.SqlClient for the provider name. You'd also need to make sure in your code that you're using the appropriate library - System.Data.SqlClient is for Microsoft SQL Server. You'd need to obtain an appropriate library from NuGet for MySQL or MariaDB. – mason Jan 18 '23 at 14:38

0 Answers0