Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 748087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:16:47+00:00 2026-05-14T14:16:47+00:00

I have a working controller for another stored procedure in the database, but I

  • 0

I have a working controller for another stored procedure in the database, but I am trying to test another.

When I request the URL;

http://host.com/Map?minLat=0&maxLat=50&minLng=0&maxLng=50

I get the following error message, which is understandable but I can’t seem to find out why it occurs;

Procedure or function
‘esp_GetPlacesWithinGeoSpan’ expects
parameter ‘@MinLat’, which was not
supplied.

This is the code I am using.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using System.Data;
    using System.Text;
    using System.Data.SqlClient;

namespace prototype.Controllers
{
    public class MapController : Controller
    {
        //Initial variable definitions
        //Array with chars to be used with the Trim() methods
        char[] lastComma = { ',' };

        //Minimum and maximum lat/longs for queries
        float _minLat;
        float _maxLat;
        float _minLng;
        float _maxLng;


        //Creates stringbuilder object to store SQL results
        StringBuilder json = new StringBuilder();

        //Defines which SQL-server to connect to, which database, and which user
        SqlConnection con = new SqlConnection(...connection string here...);

        // 
        // HTTP-GET: /Map/ 

        public string CallProcedure_getPlaces(float minLat, float maxLat, float minLng, float maxLng)
        {
            con.Open();

            using (SqlCommand cmd = new SqlCommand("esp_GetPlacesWithinGeoSpan", con))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@MinLat", _minLat);
                cmd.Parameters.AddWithValue("@MaxLat", _maxLat);
                cmd.Parameters.AddWithValue("@MinLng", _minLng);
                cmd.Parameters.AddWithValue("@MaxLng", _maxLng);


                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        json.AppendFormat("\"{0}\":{{\"c\":{1},\"f\":{2}}},", reader["PlaceID"], reader["PlaceName"], reader["SquareID"]);
                    }
                }
                con.Close();
            }
            return "{" + json.ToString().TrimEnd(lastComma) + "}";
        }


        //http://host.com/Map?minLat=0&maxLat=50&minLng=0&maxLng=50
        public ActionResult Index(float minLat, float maxLat, float minLng, float maxLng)
        {
            _minLat = minLat;
            _maxLat = maxLat;
            _minLng = minLng;
            _maxLng = maxLng;

            return Content(CallProcedure_getPlaces(_minLat, _maxLat, _minLng, _maxLng));
        }
    }
}

Any help on resolving this problem would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:16:48+00:00Added an answer on May 14, 2026 at 2:16 pm

    Your CommandType is wrong. It should be:

    cmd.CommandType = CommandType.StoredProcedure;
    

    Since you’re using CommandType.Text, my guess would be that ADO.NET is trying to map parameters into the text of the query rather than generating the proper call to the Stored Procedure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.