Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:49:39+00:00 2026-06-01T05:49:39+00:00

i have a webservice and a comsumer, the webservice has its methode where it

  • 0

i have a webservice and a comsumer, the webservice has its methode where it returns data from a mysql database.
in the comsumer i called

WebService.Service1 Service = new WebService.Service1();        

in the beginning (not within a methode)
when the consumer starts asking for data it will be 20 requests within 10 minutes first 15-18 requests worked perfectly but the last few times it returns the error

Server was unable to process request. —> The connection is already
open.

I hope i provided enough information like this, i rather not post the code.

This is the methode of the webservice:

        public string GetAnswer(string Question, string Option1, string Option2, string Option3, string Option4)
    {
        string connstring = "Server=Server;Port=3306;Database=DB;UID=User;password=pw;";
        MySqlConnection conn = new MySqlConnection(connstring);
        MySqlCommand command = conn.CreateCommand();

        command.CommandText = "SELECT * FROM `tbl` where `Question` = '" + Question + "' LIMIT 1";
        conn.Open();

        MySqlDataReader reader = command.ExecuteReader();
        if (reader.HasRows)
        {
            string TheAnswer = "";
            while (reader.Read())
            {
                string question = reader["Question"].ToString();
                string answer = reader["Answer"].ToString();
                if (Option1.Equals(answer))
                    TheAnswer = Option1;
                if (Option2.Equals(answer))
                    TheAnswer = Option2;
                if (Option3.Equals(answer))
                    TheAnswer = Option3;
                if (Option4.Equals(answer))
                    TheAnswer = Option4;
            }
            conn.Close();
            conn.Dispose();
            return TheAnswer;
        }
        else
        {
            MySqlCommand command2 = conn.CreateCommand();
            command.CommandText = "Insert Into `new` (`Question`, `Answer1`,`Answer2`,`Answer3`,`Answer4`) VALUES ('" + Question + "','" + Option1 + "','" + Option2 + "','" + Option3 + "', '" + Option4.Replace("~", " ") + "')";
            conn.Open();
            command.ExecuteNonQuery();

            conn.Close();
            conn.Dispose();
            return "Error: Question is unknown, saving the question to get it answered.";
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:49:41+00:00Added an answer on June 1, 2026 at 5:49 am

    You have conn.open() in your else statement, and the connection was already opened before that. You should probably consider using the using statement:

    using (MySqlConnection conn = new MySqlConnection(connstring))
    {
      using (MySqlCommand command2 = conn.CreateCommand())
      {
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webservice method that reads a photo and returns its byte data.
I have a webservice (ie. servlet) implemented in Java. It gets some data from
I have webservice(WCF) and MembershipProvider/RoleProvider to check credentials. When service called - various methods
Currently I have webservice running on the Mono platform. When I call the service
I have a WebService that returns XML in a SOAP response: <?xml version=1.0 encoding=utf-8
I have a webservice that returns a list of Clinics near a certain lat/long.
I have following webservice: [webmethod] public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
I have a WCF service (.NET 4) hosted in IIS. My service contract has
I have a .Net web service that processes AES encrypted data. The consumers of
I have WebService: public class Service1:WebService { private readonly MNConnection _conn; private MNLpu _lpu;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.