Return Datalayer value

Asked

Viewed 28 times

1

Good afternoon.

I have a precedent that makes some commands and returns 0 = success; 1 = without success;

 alter PROCEDURE [dbo].TesteRetorno
    (
        @DS_NOME_ARQUIVO_SINCRONISMO AS VARCHAR(200) = null
    )

    AS

    if exists(select top 1 ID_USUARIO from BCS_USUARIO where ID_USUARIO = 'brisa')
    begin

    return 0 

    end 

    else
return 1

I’d like to use that feedback in my C code#.

    ParameterCollection oP = new ParameterCollection();
    oP.Add("@DS_NOME_ARQUIVO_SINCRONISMO", "", DbType.String);

    var retorno = DataLayer.ExecuteNonQuery("TesteRetorno", oP).ToString();

But I never get anything back;

follows the Datalayer class

#region Assembly brsBiblioteca.dll, v1.0.3.0
// C:\Users\ctorres\Documents\Projetos\FSLexMark\Legado\FRAMEWORK v3.5\LEXMARK\SAP\MigracaoSAP_V4\Packages\brsBiblioteca.dll
#endregion

using System;
using System.Data;

namespace Biblioteca.Data
{
    public sealed class DataLayer
    {
        public DataLayer();

        public static void ExecutarCommand(string pstrCommandText, ParameterCollection phtParameters);
        public static void ExecutarCommand(string pstrCommandText, ParameterCollection phtParameters, string strConexao);
        public static void ExecutarCommand(IDbConnection objConnection, IDbTransaction objTransaction, string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static DataSet ExecuteDataset(string pstrCommandText);
        public static DataSet ExecuteDataset(string pstrCommandText, ParameterCollection phtParameters);
        public static DataSet ExecuteDataset(string pstrCommandText, ParameterCollection phtParameters, string strConexao);
        public static DataSet ExecuteDataset(IDbConnection conn, IDbTransaction tran, string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static DataSet ExecuteDatasetNoTransaction(string pstrCommandText);
        public static DataSet ExecuteDatasetNoTransaction(string pstrCommandText, ParameterCollection phtParameters);
        public static DataSet ExecuteDatasetNoTransaction(IDbConnection conn, string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static DataSet ExecuteDatasetNoTransaction(string pstrCommandText, ParameterCollection phtParameters, string strConexao);
        public static int ExecuteNonQuery(string pstrCommandText);
        public static int ExecuteNonQuery(string pstrCommandText, ParameterCollection phtParameters);
        public static int ExecuteNonQuery(string pstrCommandText, ParameterCollection phtParameters, string strConexao);
        public static int ExecuteNonQuery(IDbConnection objConnection, IDbTransaction objTransaction, string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static object ExecuteScalar(string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static object ExecuteScalar(string pstrNomeStoredProcedure, ParameterCollection phtParameters, int Timeout);
        public static object ExecuteScalar(IDbConnection conn, IDbTransaction tran, string pstrNomeStoredProcedure, ParameterCollection phtParameters);
        public static object ExecuteScalar(IDbConnection conn, IDbTransaction tran, string pstrNomeStoredProcedure, ParameterCollection phtParameters, int TimeOut);
        public static IDbCommand GetCommand();
        public static IDbConnection GetConnection();
        public static IDbConnection GetConnection(string pstrConnectionString);
        public static IDbDataAdapter GetDataAdapter(IDbCommand cmd);
        public static DbType GetDbType(DbType pDbType);
        public static System.Data.OracleClient.OracleType GetOracleType(DbType pDbType);
    }
}
  • What is DataLayer?

  • Datalayer is a library of the Biblioceta namespace.Data I can also do it with another command.

  • So you need the method code ExecuteNonQuery, think not?

  • edited the question

  • And the implementation of the method, where it is?

  • apparently ExecuteNonQuery will always return an int, maybe you should use the ExecuteScalar or check if it would be the case of returning the value per parameter

  • I don’t have the implementation of the Method, it’s a Library.

  • has documentation at least ?

  • Bá, jovem. You need to at least know how the method should work, otherwise all you can do is shoot in the dark.

  • @Juniortorres tried with the ExecuteScalar ?

  • Thanks for the help, it’s a little harder than I thought. Can you close the question please

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.