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

  • Home
  • SEARCH
  • 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 8589541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:04:53+00:00 2026-06-11T23:04:53+00:00

I have a stored procedure which I am calling which will return data from

  • 0

I have a stored procedure which I am calling which will return data from a table.

But when I try to populate an .aspx with the data it skips my method from doing it because my method is based on whether a reader detects rows.

Here is my method:

private void editExhibit(int expenseID)//new
{
  saveExhibitBtn.Text = "Update Exhibit";

  SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSCIDConnectionString"].ToString());
  SqlCommand cmd = new SqlCommand("p_CaseFiles_Exhibits_RetrieveExhibitDetails", conn);
  cmd.CommandType = CommandType.StoredProcedure;
  //cmd.Parameters.AddWithValue("@ExhibitID", expenseID);
  cmd.Parameters.Add(new SqlParameter("@ExhibitID", SqlDbType.Int));
  cmd.Parameters["@ExhibitID"].Value = expenseID;

  bool hasAttachments = false;
  string investigatorID = "";
  //bool alreadyInvoiced = false;
  bool isExpenseOwner = false;
  string fileID = "-1";

  try
  {
      conn.Open();
      var reader = cmd.ExecuteReader();
      if (reader.HasRows)//////////////////////craps out here bcause hasRows is false....
      {
          reader.Read();
          fileID = reader["FileID"].ToString();
          ddlCaseFiles.SelectedValue = fileID;
          ddlCaseFiles.Enabled = false;
          // retrieve exhibit details here
          hasAttachments = (bool)reader["HasAttachments"];
          investigatorID = reader["InvestigatorID"].ToString();
          if (Session["InvestigatorID"].ToString() == investigatorID)
          {
              isExpenseOwner = true;
          }
          txtDateReceived.Value = reader["SeizeDate"].ToString();
          ddlReceivedBy.SelectedValue = reader["SeizedByInvestigatorID"].ToString();
          txtTimeReceived.Value = reader["SeizeTime"].ToString();
          txtWhyHowReceived.Value = reader["SeizeAuthority"].ToString();
          txtReceivedLocation.Value = reader["SeizeLocation"].ToString();
          txtOurItemNum.Value = reader["NewExhibitOutItemNumber"].ToString();////////////
          txtTheirItemNum.Value = reader["ClientItemNum"].ToString();
          txtBagNum.Value = reader["BagNumber"].ToString();
          txtBoxNum.Value = reader["BoxNumber"].ToString();
          txtComment.Value = reader["ExhibitDecriptionPlainText"].ToString();
      }
  }
  catch (SqlException ex)
  {
      ErrorLogger.Log(ex.Number, "NewExhibit.aspx - editExhibit - Retrieve Details", ex.Message);
  }

Here is my stored procedure:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[p_CaseFiles_Exhibits_RetrieveExhibitDetails]
  @FilterField nvarchar(max)=null
, @FilterQuery nvarchar(max)=null
, @SortName nvarchar(max)='SeizeDate, SeizeTime '
, @SortOrder nvarchar(max)='desc'
, @ExhibitID int
as
SET CONCAT_NULL_YIELDS_NULL OFF
declare @Command nvarchar(max)
Select @Command = 'select E.ExhibitID,convert(nvarchar,SeizeDate,111) as ''SeizeDate'',SeizeTime,ExhDesc,E.InvestigatorID as ''EnteredBy'' 
  ,E.SeizedByInvestigatoID as ''SeizedBy'',SBI.ActiveInvestigator, SBI.FName+'' '' + SBI.LName as ''SeizedByName'', E.FileID,[FileName]
  ,Investigators.FName,Investigators.LName,SzAuthority,Location,ItemID,SubItemID1,SubItemID2,SubItemID3,PageSerial,ClientItemNum,Privileged
  ,Private,E.HasAttachments,ItemEntryGradeID,BagNumber,BoxNumber,PL.PropertyId,P.PropertyTypeID,P.PropertyMakeID,P.PropertyModelID,SerialNumber,ColorID
  ,cast(ItemID as varchar)+''-''+cast(SubItemID1 as varchar)+''-''+cast(SubItemID2 as varchar)+''-''+cast(SubItemID3 as varchar) as ''ItemNumber'',StoredLocally 
  from CaseFileExhibits E 
  join Investigators on E.InvestigatorID = Investigators.InvestigatorID 
  join Investigators SBI on SBI.InvestigatorID=E.SeizedByInvestigatoID 
  join CaseFiles on E.FileID = CaseFiles.FileID 
  left join CaseFileExhibitPropertyLink PL on E.ExhibitID=PL.ExhibitID 
  left join Element09a_Properties P on P.PropertyID=PL.PropertyId 
  left join ElementPropertyTypes PT on PT.PropertyTypeID=P.PropertyTypeID 
  left join ElementPropertyMakes PM on PM.PropertyMakeID=P.PropertyMakeID 
  left join ElementPropertyModels PMD on PMD.PropertyModelID=P.PropertyModelID 
  where E.ExhibitID='+convert(nvarchar,@ExhibitID);
if(@FilterQuery is not null)
begin
  select @Command+=' and '+@FilterField+ ' like '''+@FilterQuery+''' ';
end
select @Command+=' order by '+@SortName+' '+@SortOrder

So according to the stored procedure I only need to pass in the exhibitID, which I did.

  • 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-06-11T23:04:54+00:00Added an answer on June 11, 2026 at 11:04 pm

    Your Stored procedure looks incomplete. You probably need to add

    exec sp_executesql @command;
    

    At the end to get it to return your rows.

    info about sp_executesql can be found at http://msdn.microsoft.com/en-us/library/ms188001.aspx

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

Sidebar

Related Questions

I have created a stored procedure which will return a set of data. In
I have a stored procedure which update a table based on such calculation and
I have a stored procedure which accepts a User defined table type called SeasonTable
I have a stored procedure which takes an XML parameter and inserts the data
I have a stored procedure which returns an integer value. Can I return a
I have an Oracle trigger which is calling a stored procedure that has PRAGMA
I have a stored procedure in Oracle 9i which inserts records in a table.
We have a page calling a Search stored procedure which internally uses SQL Server
I have created a stored procedure in SQL Server, which runs immediately from Management
Hi I have an MVC app I'm calling a stored procedure from. The reason

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.