Stored procedure not found?

Discussion in 'Databases' started by deoxyrybose, May 11, 2022.

  1. New to web development, this is my first deployment. Used visual studio to deploy two MS SQL databases, one for identity server log ins, and one for app data. The identity server works fine, but the app data one will not access the stored procedures. I ran this app from VS2022, with these same two winhost databases attached, and my app runs fine in debug. When I run the app from the winhost site at my url, it crashes ONLY when I attempt to use pages that require those stored procedures.

    Confirmed stored procedure exists, code looks good, and confirmed this database WORKS when using debug from visual studio 2022, just not when accessing my site deployed on the web.

    Here is the error I get from chrome browsers F12 console...

    blazor.server.js:1 [2022-05-11T14:24:47.943Z] Error: System.Data.SqlClient.SqlException (0x80131904): Could not find stored procedure 'dbo.spLoadDepartmentsByCompany'.

    at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__126_0(Task`1 result)

    at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()

    at System.Threading.Tasks.Task.<>c.<.cctor>b__271_0(Object obj)

    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

    --- End of stack trace from previous location ---

    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

    --- End of stack trace from previous location ---

    at Dapper.SqlMapper.QueryAsync[T](IDbConnection cnn, Type effectiveType, CommandDefinition command) in /_/Dapper/SqlMapper.Async.cs:line 418

    at DataAccessLibrary.Internal.SqlDataAccess.LoadData[T,U](String storedProcedure, U parameters) in C:\Users\ryana\source\repos\DashboardApp\DataAccessLibrary\Internal\SqlDataAccess.cs:line 30

    at BlazorServer.Pages.Landing.SetClaimsContext() in C:\Users\ryana\source\repos\Dashboard\BlazorServer\Pages\Landing.razor:line 158

    at BlazorServer.Pages.Landing.OnInitializedAsync() in C:\Users\ryana\source\repos\Dashboard\BlazorServer\Pages\Landing.razor:line 128

    at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

    at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

    ClientConnectionId:10d729a8-eebc-4f2c-8cbd-8ee73d8a6d6c

    Error Number:2812,State:62,Class:16
     
    Last edited: May 11, 2022
  2. Accessing the database from https://sqladmin.winhost.com/mylittleadmin.aspx, I was able to successfully execute the offending stored procedure... but the app still crashes when calling that stored procedure from WinHost, but not from VS2022 debug.
     

    Attached Files:

  3. Elshadriel

    Elshadriel Winhost Staff

    Can't really say without looking at your code, but I'll ask the obvious. Are you using the right connection string? (i.e. it's pointing to the Winhost databases and not a local one?)
     
  4. Solved!

    The publish dialog box in VS has a drop down menu that I didn't realize was a drop down. The connection strings were coded correctly in the app, but the publisher had the same connection string listed for both. Thanks again!
     

    Attached Files:

    Last edited: May 11, 2022
    Elshadriel likes this.

Share This Page