尝试连接到我在我拥有的域下创建的远程(GoDaddy)MySQL数据库。我使用的是c#,而不是php。
web.config中的IP地址由Plesk的GoDaddy提供。
收到以下错误:
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '[UserProfile]([UserId] int NOT NULL
PRIMARY KEY IDENTITY, [Email] nvarchar(56) N' at line 1
这是我的web.config(以及相关的连接字符串):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
</system.webServer>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off" />
</system.web>
<system.data>
</system.data>
<connectionStrings>
<add connectionString="Server=50.62.209.107;Port=3306;Database=RP;Uid=my_userid;Pwd=my_password" name="RP" providerName="MySql.Data.MySqlClient"></add>
<add connectionString="Server=localhost;Port=3306;Database=RP;Uid=my_userid;Pwd=my_password" name="RP_Local" providerName="MySql.Data.MySqlClient"></add>
</connectionStrings>
<appSettings>
<add key="enableSimpleMembership" value="true" />
</appSettings>
</configuration>
我能够在MySQL Workbench中使用这些相同的参数,并且没有问题地访问数据库。
任何帮助表示赞赏。谢谢!
答案 0 :(得分:1)
试试这个
<add name="connstring" connectionString="server=localhost;User Id=root;Persist Security Info=True;database=marctest;password=PASSWORD" providerName="MySql.Data.MySqlClient"/>