Reputation: 13
I have database function in main asp.net project and just created separate wcf project and trying to call database function in wcf. below code is one function in svc
public string ValidateUser(string username, string pwd)
{
myApplication application = new myApplication();
string resultString = string.Empty;
try
{
resultString = application.Application.User.GetUserIdByUserName(username, pwd).ToString();
}
catch(Exception e)
{ resultString = "exception:" + e.Message; }
return resultString;
}
What the database function does is check whether user name exist in table(MSSQL) and if it does it will return userId.
I thought it will be straight forward but every time I call this function I get nullException error
and I guess it's because the database function when it complies, it looks up the connection string from web.config
in main project but it stores null value.
I'm testing this locally with two VS open; one is main asp.net project with wcf project and another VS for console application to call this wcf.
Any suggestion or advise will be much appreciated.
Upvotes: 1
Views: 217
Reputation: 4232
Can you clarify which .config
file has the database connection string? The WCF service project or the ASP.NET project that calls it? The code running within the WCF service will get it's configuration from the WCF project's .config
file, if the connection string isn't there, it won't get it from the caller.
Upvotes: 1