WebServices exception

W

weird0

When i execute the desktop application that creates a webservice obj
and connects to a db, it gives the following exception:

Server was unable to process request---> An error occured while
establishing connection to the server. When connecting SQL Server
2005, this failure may be caused by the fact that under the default
settings SQL Server does not allow remote connections ( provider 40-
Could not open a connection to SQL Server).

Can anyone tell me the solution to this problem? Or why is it
occuring? I feel the problem is with the config. of SQL Server or the
problem seems to be with the connection string.

Here is the connectionstring: (webservice is being tested locally)

public static string connectionString = @"server=amirdiwan;database=|
DataDirectory|\BankingDb.mdf;";


Urgent
Need help
 
N

Nicholas Paldino [.NET/C# MVP]

Well, what are you using for credentials? I think that in the absence
of any user id/password, it resorts to trusted connections, in which case,
it is going to use the local ASPNET account to connect to SQL Server, which
in the default case, will always fail (the SQL Server can't know about the
ASPNET account, and unless you moved the ASPNET account into the
administrators group, and the SQL Server is on the local machine, you
shouldn't be able to connect).

To fix this, you either have to change your web service so it runs under
a user account which has access to the database, or use a login in the
connection string to connect to the database.

Hope this helps.
 
W

weird0

Hey Nicholas,

May be you are absolutely right. But what should be username and the
password in my connection string and how do
I find what is the username and password?

Do i have to create a login? If yes, how?
 
W

weird0

public static string connectionString = @"server=amirdiwan;database=|
DataDirectory|\BankingDb.mdf; user id=sa; password=sa; "

I tried this connectionstring and also tried username=mappedname and
password=MyWebAppUser which is stored int he we.config of ASP.net
which i suppose is defined for my db in the appp settings.
<appsettings>
<add key="mappedname" value="MyWebAppUser">
</appsettings>

Please tell me what to dooo... How to set the username and password
for the db in the ASP.net application and then use it inside the
webservice connectionstring.

Me a newbie to webservices and tireed of facing the issues with it
which wastes my days and work cant go on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top