开发者

Not all variables bound (but they are there)

开发者 https://www.devze.com 2023-01-07 04:54 出处:网络
I am having a problem with this method. All the parameters are there, and in order, but I still get this error: ORA-01008: not all variables bound

I am having a problem with this method. All the parameters are there, and in order, but I still get this error: ORA-01008: not all variables bound

protected void LastUpdateDates(string Path, string Key, bool Update)
        {
            //load the update dates of the mta files 
            try
            {
                FileInfo file = new FileInfo(Path);
                string query = string.Empty;

                if (myOleDbConnection.State == ConnectionState.Closed) { myOleDbConnection.Open(); }
                OleDbCommand myOleDbCommand = new OleDbCommand();                
                query = "UPDATE USER_LINK_MTA_LOGS SET DT_ATUALIZACAO=:PDT, DS_CAMINHO=:PFULLNAME WHERE ID_ARQUIVO=:PKEY";


                myOleDbCommand.Connection = myOleDbConnection;
                myOleDbCommand.CommandText = query;
                myOleDbCommand.Parameters.AddWithValue(":PDT", file.LastWriteTime);
                myOleDbCommand.Parameters.AddWithValue(":PFULLNAME", file.FullName);
                myOleDbCommand.Parameters.AddWithValue(":PKEY", Key);

                myOleDbCommand.ExecuteNonQuery();

                myOleDbCommand.Dispose();


            }
            catch (Exception exxx)
            {
                ErrorHandler.TreatError("Could not obtain MTA configuration\r\n" + exxx);
            }

        }

now i tried with the ? place holder as Skeet says:

myOleDbCommand.Parameters.Add(file.LastWriteTime.ToString(),OleDbType.DBTimeStamp);
myOleDbCommand.Parameters.Add(file.FullName,OleDbType.VarChar);
myOleDbCommand.Parameters.Add(Key,OleDbType.VarChar);

The way above I got the error below when i run the ExecuteNonQuery.

Parâmetro [0] '' não tem valor padrão. Translate: Paramenter [0] has no standard value.

Parâmetro [1] '' não tem valor padrão.

Parâmetro [2] '' não tem valor padrão.

Also tried this way below, and got an error when tring to set the parameter.

myOleDbCommand.Parameters.Add(file.LastWriteTime);
myOleDbCommand.Parameters.Add(file.FullName);
myOleDbCommand.Paramet开发者_StackOverflow中文版ers.Add(Key);

OleDbParameterCollection só aceita objetos do tipo OleDbParameter não nulos, não aceita objetos DateTime.

Translate: OleDbParameterCollection only acepts non-null objets of the type OleDbParameter. Do not accept objets of the DateTime Type.


According to the docs for OleDbCommand.Parameters you can't use named parameters:

The OLE DB .NET Provider does not support named parameters for passing parameters to an SQL statement or a stored procedure called by an OleDbCommand when CommandType is set to Text. In this case, the question mark (?) placeholder must be used.

Have you tried using placeholders instead?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号