C# 从c调用的firebird存储过程中的更新表#

C# 从c调用的firebird存储过程中的更新表#,c#,stored-procedures,firebird,C#,Stored Procedures,Firebird,我在firebird中有以下存储过程: create or alter procedure "LKS_CambiaEstadoAgenda" ( "param_id" integer) as begin update "Agenda" set "Agenda".estatus = 2 where "Agenda"."idAgenda" = :"param_id"; end 这个C#代码: 当我执行它时,它不会在数据

我在firebird中有以下存储过程:

create or alter procedure "LKS_CambiaEstadoAgenda" (
    "param_id" integer)
as
begin
    update
        "Agenda"
    set
        "Agenda".estatus = 2
    where
        "Agenda"."idAgenda" = :"param_id";
end
这个C#代码:


当我执行它时,它不会在数据库中进行更改。我的代码中有什么错误,或者您可以给我什么建议?

您需要提交事务。可以看到一个例子

public bool cambioEstadoAgenda(int idAgenda)
{
        ConectarBD();

        try
        {
            comando.CommandType = CommandType.StoredProcedure;
            comando.CommandText = "\"LKS_CambiaEstadoAgenda\"";

            comando.Parameters.Clear();
            comando.Parameters.AddWithValue("@param_id", idAgenda);

            comando.Connection = conexion;

            if (Convert.ToInt32(comando.ExecuteScalar()) > 0)
                return true;
            else
                return false;
        }
        catch (Exception ex)
        {
            MessageBox.Show("ups. un error\n" + ex.Message);
            return false;
        }
        finally
        {
            comando.Parameters.Clear();
            DesconectarBD();
        }
}
2. Update a text blob field

public static void Main(string[] args)
{
// Set the ServerType to 1 for connect to the embedded server
string connectionString =
"User=SYSDBA;" +
"Password=masterkey;" +
"Database=SampleDatabase.fdb;" +
"DataSource=localhost;" +
"Port=3050;" +
"Dialect=3;" +
"Charset=NONE;" +
"Role=;" +
"Connection lifetime=15;" +
"Pooling=true;" +
"Packet Size=8192;" +
"ServerType=0";

FbConnection myConnection = new FbConnection(connectionString);
myConnection.Open();

FbTransaction myTransaction = myConnection.BeginTransaction();

FbCommand myCommand = new FbCommand();

myCommand.CommandText =
"UPDATE TEST_TABLE_01 SET CLOB_FIELD = @CLOB_FIELD WHERE INT_FIELD = @INT_FIELD";
myCommand.Connection = myConnection;
myCommand.Transaction = myTransaction;

myCommand.Parameters.Add("@INT_FIELD", FbType.Integer, "INT_FIELD");
myCommand.Parameters.Add("@CLOB_FIELD", FbType.Text, "CLOB_FIELD");

myCommand.Parameters[0].Value = 1;
myCommand.Parameters[1].Value = GetFileContents(@"GDS.CS");

// Execute Update
myCommand.ExecuteNonQuery();

// Commit changes
myTransaction.Commit();

// Free command resources in Firebird Server
myCommand.Dispose();

// Close connection
myConnection.Close();
}

public static string GetFileContents(string fileName)
{
  StreamReader reader = new StreamReader(new FileStream(fileName, FileMode.Open));
  string contents = reader.ReadToEnd();
  reader.Close();
  return contents;
}