Error when trying to use SQL Server database

Morpheus

Well-known member
Joined
Jan 18, 2002
Messages
62
When a user try to access my database from my asp.net webapplication this error pops up:

Server Error in /WebApplication1 Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the applications <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>

I can access the database locally but not from the internet. I understand that it has something to do with permissions but what can I do about it?
 
Heres the one in web.config

sqlConnectionString="data source=127.0.0.1;user id=sa;password="

And heres the one in my code:

string myConnectionString = @"Initial Catalog=kundhantering;Data Source=localhost;Integrated Security=SSPI;";
SqlConnection myConnection = new SqlConnection(myConnectionString);
 
of course you cant acces your database from internet, because you use "127.0.0.1" and "localhost" in your connection string, it is no problem if your IIS server and database always locate at same machine/server.

If your database locate in different machine, then you should change the IP to which machine IP your database located (IP 127.0.0.1 mean localhost or local machine, you should change it to real IP address - Fixed IP request)
 
Yeah that sounds logic.

Thank you very much!

But my database and IIS is always on the same machine.
 
If it is always at the same machine, then as long as you can access your Web Application, then it is definitely no problem. Because all processes with database is in your IIS which locate the same as your database.
 
Well the problem is there.

Maybe I have to do like this?
sqlConnectionString="data source=127.0.0.1:8080;user id=sa;password="
 
I have one function that access the database directly from the webapplication and it works. So the error occur when the webapplication try to use the webservice.

Any ideas?
 
Back
Top