2
votes

i am having trouble with the Connection String in C#

the database is on the server via phpmyadmin(i do not own the server its online)

got hosting via GoDaddy as well as GlobeHost but with both same problem

my current connection srting is string strcon = "Server=ipAddress(OfServer);Database=testing;Uid=myusername;Pwd=mypassword";

and i am getting this error while Connection.Open();

check the link testing page

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=**************' failed.

2

2 Answers

0
votes

Your web host has configured the server to block outbound connections, at least specifically on your website and possibly that port number.

Speak to your web host to find out if you can be granted permission or if other ports are unblocked (though this is a Code Access Security configuration, so I doubt it depends on the port setting at all) - if not then you will not able to use an external database at all.

Note that using an off-site DB will generally result in very poor performance because of network latency. Is there a reason you're not using a DB provided by your host?

0
votes

Connection String format is wrong. It has to be

connectionString="Server=192.168.0.XX;Database=DBname;User Id=bdusername;Password=dbpassword;"