D
D
DmJ2013-10-20 23:24:27
firebird
DmJ, 2013-10-20 23:24:27

Calling a Procedure with Parameter Passing

after describing the connections...

            try
            {
                connectionsql.Open();
                connectionfirebird.Open();

                cmdS.CommandText = "select ID_CASH from CAHS_TRANSACT";
                SqlDataReader reader;
                reader = cmdS.ExecuteReader();
                while (reader.Read())
                {
                    str = "execute procedure ART_DOC_INSERT (:ID_CASH, :DOCNUMB, :FLG)";
                    cmdF.CommandText = str;
                    cmdF.Parameters.Add("@ID_CASH", FbDbType.Integer).Value = reader.GetInt32(0);
                    cmdF.Parameters.Add("@DOCNUMB", FbDbType.BigInt).Value = DateTime.Now.ToString("yyMMddhhmm");
                    cmdF.Parameters.Add("@FLG", FbDbType.Integer).Value = "1";
                    try
                    {
                        cmdF.Prepare();
                        cmdF.ExecuteNonQuery();
                        cmdF.Parameters.Clear();
                    }
                    catch (Exception ex2)
                    {
                        Console.WriteLine(ex2.Message);
                        Console.ReadLine();
                    }
                }

gives an error:
Dynamic SQL Error
SQL error code = -206
Column unknown
ID_CASH
At line 1, column 36
What is my mistake? Thank you!

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander, 2013-10-21
@avorsa

Based on this or this , the code will be like this:

str = "execute procedure ART_DOC_INSERT (:ID_CASH, :DOCNUMB, :FLG)";
cmdF.CommandText = str;
cmdF.Parameters.Add("ID_CASH", FbDbType.Integer).Value = reader.GetInt32(0);
cmdF.Parameters.Add("DOCNUMB", FbDbType.BigInt).Value = DateTime.Now.ToString("yyMMddhhmm");
cmdF.Parameters.Add("FLG", FbDbType.Integer).Value = "1";

look carefully at the links provided, maybe you will find something else useful)

D
DmJ, 2013-10-21
@DmJ

Thanks, I'll take a look at the links, of course, but your code shows the same error!

A
Alexander, 2013-10-21
@avorsa

text of the procedure

D
DmJ, 2013-10-21
@DmJ

thank! figured it out myself.
this is correct:
str = "execute procedure ART_DOC_INSERT (@ID_CASH, @DOCNUMB, @FLG)";
cmdF.CommandText = str;
cmdF.Parameters.Add("ID_CASH", FbDbType.Integer).Value = reader.GetInt32(0);
cmdF.Parameters.Add("DOCNUMB", FbDbType.BigInt).Value = DateTime.Now.ToString("yyMMddhhmm");
cmdF.Parameters.Add("FLG", FbDbType.Integer).Value = "1";

A
Alexander, 2013-10-21
@avorsa

that's great! )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question