Last post Feb 02, 2017 08:06 PM by adamturner34
Feb 01, 2017 05:35 PM|acmedeepak|LINK
I have the below stored procedure and C# code.
ALTER PROCEDURE [dbo].[ItemDetailsPicker]
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select pop.itemnmbr,cast(round(AVG(pop.unitcost),2) as decimal(10,2)) as cost
from AFS.dbo.POP10110 pop
where pop.REQDATE >=DateAdd(day,-14, getdate()) group by pop.itemnmbr
protected void BtnGetErPData_Click(object sender, EventArgs e)
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
string afsconstring = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
using (SqlConnection con = new SqlConnection(afsconstring))
using (SqlCommand cmd = new SqlCommand("ItemDetailsPicker", con))
cmd.CommandType = CommandType.StoredProcedure;
lblMessage.CssClass= "alert alert-success";
lblMessage.Text = "Msg 23: Data updated successfully";
txtItemNumber.Text = "";
txtCost.Text = "";
txtDescription.Text = "";
lblMessage.CssClass = "alert alert-warning";
lblMessage.Text = "Msg 23: something went wrong. Please try again";
The code returns
Msg 23: Data updated successfully
But the data is not populated in the IC_Item_M table.
Feb 01, 2017 05:57 PM|ryanbesko|LINK
None of the code you posted has an UPDATE statement, only a SELECT statement. And then it sets the lblMessage.Text property to "Msg 23: Data updated successfully".
Feb 02, 2017 07:43 AM|Eric Du|LINK
According to your description and code, it can show "Msg 23: Data updated successfully", I think code have no problem. I notice in BtnGetErPData_Click, you don't use data table or data set to load returned data, I guess you have get the returned data and
no code to populate IC_Item_M table. My suggestion is add dataset to load returned data and populate it to IC_Item_M table.
Feb 02, 2017 08:06 PM|adamturner34|LINK
You do know that your stored procedure only has a "SELECT" and not an "UPDATE" statement right?