Asynchronous Function in C# Web

Asked

Viewed 52 times

1

I am making a web page that does a database search and using in only one machine everything is normal, however, when the search is used more than once, as for example, in two different machines, the error search.

I tested other search modes, but also the error, I wanted to know if there is any way to leave this asynchronous search with the mode async/await or something like, follows the search and error:

public static FbDataAdapter GetDataAdapter(string query)
{
    FbConnection myConn = ConnectionFB.GetInstance().GetConnectionFb();

    myConn.Close();
    myConn.Open();
    FbDataAdapter da;
    try
    {
        da = new FbDataAdapter(new FbCommand(query, myConn));
    }
    catch (Exception ex)
    {
        throw new Exception("Impossível criar tabela a partir de uma instrução SQL.",
           ex.InnerException);
    }
    return da;
}

public static DataSet GetData(string query)
{
    DataSet ds = new DataSet("dsPadrao");
    try
    {
        FbConnection.ClearAllPools();
        FbDataAdapter da = new FbDataAdapter(new FbCommand(query, myConn));
        da.Fill(ds);
    }
    catch (Exception ex)
    {
        throw new Exception("Impossível criar dataset a partir de uma instrução SQL.", ex);
    }
    return ds;
}

That is the mistake:

Erro

the database I am using is Firebird, but I think this is not the relevant thing, since searching only once, the research does not present error.

  • Your question is so confused... Does the error happen when you repeat the search? What other machines have to do with the question? You’ve already debugged your code?

  • why are you killing all the pool on GetData()

  • makes a block using instantiating a new connection and closes it at the end

  • 2

    Your code is already strange because it closes and opens connection, without you checking if it really is open, I see problems in it, the attached error with image in your question does not really say, you have to say where really happens this error in which line and when does all this, is a local error

  • besides q not seen q has to do with one code with the other

  • Well, I’ll try to summarize here, I’m developing a web report. Apparently it’s giving conflict in the search functions. As this report can be used in more than one location, as in two different Pcs, it breaks down when I try to generate two reports at a time, even if with different information. I was wondering if there’s any way to leave those functions in an asynchronous way. If need be, put all the forms of research I have used, and how it was reported that those posted are incorrect, how can I correct them?

Show 1 more comment

1 answer

1

Bruno by the error message all indicates that it is the query (query). If you still need help put the query.

  • Anderson, the problem itself is conflict in the use of the search function. When I research and hope it is generated, the report comes out normal. When I Gero it once and before it is generated, I search again (being on another machine or in the same), it presents the error.

  • Got it @Brunomiqueas thanks for the return.

Browser other questions tagged

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