I have made a web application, where it needs to connect to database and inserts the details from the two textboxes provided in the aplication. but while in runtime, it generates an error message that
"Sql server doesn't exists or access denied"
All the connection are coded inthe file manually.
How to minimise runtime errors in c#. net?
The connection string should not be hardcoded. It should be stored in a configuration file in one centralised place so that are not obliged to recompile your application every time you need to modify the connection string.
In your case the problem is obviously in you connection string. The error generated is quite self explaining.
In general, runtime errors cannot be avoided but rather handled. You should place code that is susceptible to throw exceptions in try - catch blocks. Code within the try scope is referred to as protected code.
For more info on try catch statements in C#, check out this link:
http://msdn2.microsoft.com/en-us/0yd65es...
Reply:Make sure the connection string defined for the connection object is valid. Check the name of the website or its IP in the connection string and try it in a WebForm and see if it works. If yes, then use it in your web application. Good luck.
Reply:Yep I got to say the same thing
Check the Web.Config file for your connection string..
long stem roses
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment