Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The returned valued being displayed as "1" is the total rows returned after the execution of your query. </p> <p>Here is a draft of what you might need to do, this is just an idea on how the data from your procedure is being treated on the code. And I am revising your sql procedure as to return the value that you are expecting in return.</p> <p>For the Code Behind:</p> <pre><code>using System.Data.SqlClient; using System.Data; public class DBAccess{ private string strCon = "Data Source=YourServer;Initial Catalog=YourDBName;etc"; public string GetResult(){ string strQuery = "Exec YourProcedure Param1"; SqlCommand cmdSql = new SqlCommand(strQuery); SqlConnection conSql = new SqlConnection(strCon); conSql.Open(); cmdSql.Connection=conSql; SqlDataReader dreSql = cmdSql.ExecuteReader(); dreSql.Read(); // here I'm trying to read the item of the row on the column named Result return dreSql["Result"].ToString(); } } </code></pre> <p>Your Procedure:</p> <pre><code>ALTER PROCEDURE dbo.sp_InsertInstruction @Flag char(1) = null, @C_Interval int=null, @D_Interval int=null, @ID char(20) AS DECLARE @Entity_ID int SET @Entity_ID = (SELECT ID FROM Entity WHERE ID = @ID) if(@Entity_ID is not null) begin INSERT INTO Instructions(Flag, C_Interval, D_Interval, Entity_ID) VALUES (@Flag, @C_Interval, @D_Interval, @Entity_ID) -- this will return as a table with the result of 1 select Result='1' end else begin -- this will return as a table with the result of 0 select Result='0' end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload