0

I want to connect my C# .NET website using Visual Studio to a MySQL database located with the host 123-REG.

I have put the following code snippet (edited for security) into my web.config file:

 < appSettings > < add key="ConnectionString" value="Server=XX; Database=XX; User Id=XX; Password=XX" / > < /appSettings > 

But now I don't know what I should put in my code to read and write to this database.

So what should my connection string look like? Also, do I need to do anything for port settings?

If anyone has already been down this path, I would really welcome your help.

1

1 Answer 1

1

Visual Studio does not have native support for MySql Database, so yo need to install MySql Connector/Net: link

After from UI you can set everything, and it will generate the connection string for you: link

[EDIT]

From http://www.connectionstrings.com/mysql

For Standard connection (Default port is 3306.)

 <connectionStrings> <add name="MyConnStr" connectionString="Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"/> </connectionStrings> 

If you need to specifie the port:

 <connectionStrings> <add name="MyConnStr" connectionString="Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"/> </connectionStrings> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the suggestion but I don't need to create my own mysql database. The host has a shared mysql database for me to use. As this is a unique set-up, I was hoping for some sort of example of what should be included in the connection string and any other key information that I may need to know. Is there anyone who can help at all?
It does not say you need to install MySql Database. It is a component (from MySql) which allows you to connect to a MySql databese from VS. But to answer to your question I updated my answer with two possible connectionstring.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.