How do I connect to my database from a .NET application? Print

  • 0

ASP.NET and other .NET applications on our Windows hosting can connect to MS SQL or MySQL databases using a connection string, usually stored in web.config or appsettings.json.

Get your database server, name, username and password from your control panel first.

MS SQL connection string

Server=SERVER_NAME;Database=DB_NAME;User Id=DB_USERNAME;Password=DB_PASSWORD;

MySQL connection string

Server=DB_HOSTNAME;Database=DB_NAME;Uid=DB_USERNAME;Pwd=DB_PASSWORD;

For MySQL you also need the MySQL Connector/NET (MySql.Data) or MySqlConnector package in your project. Replace the capital-letter values with your own details, and never commit real passwords to public code repositories.

Need help?

Open a support ticket from your FariHost Client Area or message us on WhatsApp and our team will help you.


Was this answer helpful?

« Back