Get data from a column in the database for a variable

Asked

Viewed 267 times

2

In one part of my code I have the treatment of an exception that uses this message.

 //Grava log com sucesso da importação
fundo.registerLog(Resources.MensagemSucessoImportacao);

The message is inside a file Resource, but it is concatenated.

Arquivo {0} importado com sucesso.

{0} is where my database table column will be.

My class does not have a variable that takes this column.

Detail: This column comes from a design:

 Database db = DatabaseFactory.CreateDatabase();            
 DbCommand cmd = db.GetStoredProcCommand("PR_LOG");

 //Adds other parameters
 db.AddInParameter(cmd, "P_DESCRICAO_LOG", DbType.String, logDescription);

The above structure is in another project class, within a method.

How do I take this column, play in a variable and put this variable after Resources.MensagemSucessoImportacao?

1 answer

1

If I understand, just need to use String.Format():

fundo.registerLog(String.Format(Resources.MensagemSucessoImportacao, logDescription));
  • logDescription does not exist in the context of where the message is, as I said above that part is in another project class.

  • Didn’t work :(

  • @Thamirescunha What would be the name of the variable that exists in this context, then? Can you please update your question?

  • As tbm mentioned above, in this context there is no variable that takes this column, I would have to create.. my doubt is how to take this possible variable that I will create and connect with this column..

  • @Without more details it is impossible to answer.

  • Morrison I don’t think I expressed myself well. I would like to take the name of the file and concatenate with the message. There are no columns in the database table that keep the file name.

  • I would like the message to be ex.: TEST.txt file successfully imported

Show 2 more comments

Browser other questions tagged

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