C#.NET connecting to host mysql database
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.
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>
精彩评论