[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Database db = DatabaseFactory.CreateDatabase();

Posted on 2009-02-16
7
Medium Priority
?
2,519 Views
Last Modified: 2012-08-13
We have a web service that worked fine until it was moved from server a to server b. Now when the code gets to Database db = DatabaseFactory.CreateDatabase(); to throws an error "System.NullReferenceException: Object reference not set to an instance of an object."

Any help is appreciated, the actual value
public DataSet GetTasks(string ProjUID)
    {
        DataSet ds = null;
        try
        {
            Database db = DatabaseFactory.CreateDatabase();
 
            string strQuery = "stpGetTasks";
 
            DbCommand cmd = db.GetStoredProcCommand(strQuery);
 
            db.AddInParameter(cmd, "@ProjUID", DbType.String, ProjUID);
 
            ds = db.ExecuteDataSet(cmd);
            db = null;
 
            return ds;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ds.Dispose();
        }
    }

Open in new window

0
Comment
Question by:jimseiwert
  • 4
  • 3
7 Comments
 
LVL 7

Expert Comment

by:thiyaguk
ID: 23656789
Where is Database server before moving and after moving ?
Have you also moved the production database if it is in local server (server a)? .
0
 
LVL 2

Author Comment

by:jimseiwert
ID: 23656792
the sql server was on a different server, say server c
0
 
LVL 7

Expert Comment

by:thiyaguk
ID: 23656825
can you post the stack trace.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:jimseiwert
ID: 23656831
Server Error in '/WEBPART_BOE' Application.
--------------------------------------------------------------------------------

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at Service.GetTasks(String ProjUID) in c:\Inetpub\SNCBOE_test\WebService_Boe\App_Code\Service.cs:line 36
  --- End of inner exception stack trace ---
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at Service.GetTasks(String ProjUID) in c:\Inetpub\SNCBOE_test\WebService_Boe\App_Code\Service.cs:line 36
  --- End of inner exception stack trace ---

Source Error:


Line 65:         [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetTasks", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 66:         public System.Data.DataSet GetTasks(string ProjUID) {
Line 67:             object[] results = this.Invoke("GetTasks", new object[] {
Line 68:                         ProjUID});
Line 69:             return ((System.Data.DataSet)(results[0]));
 

Source File: c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\webpart_boe\044910ac\a0a2eb27\App_WebReferences.4cial0f1.0.cs    Line: 67

Stack Trace:


[SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Service.GetTasks(String ProjUID) in c:\Inetpub\SNCBOE_test\WebService_Boe\App_Code\Service.cs:line 36
   --- End of inner exception stack trace ---]
   System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +413081
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +300
   wsSierraNevada.Service.GetTasks(String ProjUID) in c:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\webpart_boe\044910ac\a0a2eb27\App_WebReferences.4cial0f1.0.cs:67
   PSSierraNevada.Page_Load(Object sender, EventArgs e) in c:\Inetpub\SNCBOE_test\WebPart_Boe\PSSierraNevada.ascx.cs:25
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
0
 
LVL 7

Assisted Solution

by:thiyaguk
thiyaguk earned 2000 total points
ID: 23656870
The error comes on the webmethod call, when it opens a
connection to the db.

Do you use any webservices ?
0
 
LVL 7

Assisted Solution

by:thiyaguk
thiyaguk earned 2000 total points
ID: 23656875
Webservice - > http://tempuri.org/

what is this ?
are you running this website as service?
Did you moved and named this one also ?
0
 
LVL 2

Accepted Solution

by:
jimseiwert earned 0 total points
ID: 23656909
the problem has been found, it was the default database in the web.config. it was set to the incorrect database name. Thank you for your help
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question