M
Markus Freitag
Guest
Hello,
I need to call a StoredProcedure. The connection all good
The transfer value is of data type bit.
Problem is that deleting the records does not work and I don't know why.
I suspect I'm passing the value bit wrong. How do I do it right?
Do I see that right?
@ProductID is the variable from the stored procedure. (I make it BOLD)
ProductID is the table name.
Right?
CREATE PROCEDURE DeletePRODUCT_ID (@ProductID as nvarchar(20),
@Result as bit)
AS
BEGIN
-- Execute following SQL code
If @result = 1
Delete
FROM
[MAC].[dbo].[TABLEPRODUCTION]
Where
ProductID = @ProductID
If @result = 0
UPDATE
[MAC].[dbo].[TABLEPRODUCTION]
SET
Reserved = 0
WHERE
ProductID = @ProductID
END;
using (SqlCommand cmd = new SqlCommand(StoredProcedureDeleteMac, SkovDB))
{
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter RetVal = cmd.Parameters.Add("@return_value", SqlDbType.Int);
RetVal.Direction = ParameterDirection.ReturnValue;
SqlParameter IdInMacAdress = cmd.Parameters.Add("@ProductID", SqlDbType.Char, 50);
IdInMacAdress.Direction = ParameterDirection.Input;
IdInMacAdress.Value = txtMacAddress.Text;
SqlParameter IdInResult = cmd.Parameters.Add("@Result", SqlDbType.Bit, 50);
IdInResult.Direction = ParameterDirection.Input;
IdInResult.Value = 1; // true; // Convert.ToBoolean(txtState.Text);
txtReturnValue.Text = "";
int counter = 0;
cmd.ExecuteNonQuery();
var result = RetVal.Value;
Thanks in advance for your help.
Greetings Markus
Continue reading...
I need to call a StoredProcedure. The connection all good
The transfer value is of data type bit.
Problem is that deleting the records does not work and I don't know why.
I suspect I'm passing the value bit wrong. How do I do it right?
Do I see that right?
@ProductID is the variable from the stored procedure. (I make it BOLD)
ProductID is the table name.
Right?
CREATE PROCEDURE DeletePRODUCT_ID (@ProductID as nvarchar(20),
@Result as bit)
AS
BEGIN
-- Execute following SQL code
If @result = 1
Delete
FROM
[MAC].[dbo].[TABLEPRODUCTION]
Where
ProductID = @ProductID
If @result = 0
UPDATE
[MAC].[dbo].[TABLEPRODUCTION]
SET
Reserved = 0
WHERE
ProductID = @ProductID
END;
using (SqlCommand cmd = new SqlCommand(StoredProcedureDeleteMac, SkovDB))
{
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter RetVal = cmd.Parameters.Add("@return_value", SqlDbType.Int);
RetVal.Direction = ParameterDirection.ReturnValue;
SqlParameter IdInMacAdress = cmd.Parameters.Add("@ProductID", SqlDbType.Char, 50);
IdInMacAdress.Direction = ParameterDirection.Input;
IdInMacAdress.Value = txtMacAddress.Text;
SqlParameter IdInResult = cmd.Parameters.Add("@Result", SqlDbType.Bit, 50);
IdInResult.Direction = ParameterDirection.Input;
IdInResult.Value = 1; // true; // Convert.ToBoolean(txtState.Text);
txtReturnValue.Text = "";
int counter = 0;
cmd.ExecuteNonQuery();
var result = RetVal.Value;
Thanks in advance for your help.
Greetings Markus
Continue reading...