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 9253849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:19:19+00:00 2026-06-18T11:19:19+00:00

I currently have an ASP.NET WebService1.asmx . This uses SqlConnection to talk to Sql

  • 0

I currently have an ASP.NET WebService1.asmx.

This uses SqlConnection to talk to Sql Server.

I have now created WebServiceDB2.asmx which uses OdbcConnection.

I will be passing in a parameter from the front end to determine which service I use.

So for instance, in the code behind this is how I would make a regular web service call-

protected void deleteButton_Click(object sender, EventArgs e)
    {
        WebService1 ws = new WebService1();
        ws.deleteTerm(term); 
    }

My question being is there a more efficient way of implementing the option of the DB2 call than this –

protected void deleteButton_Click(object sender, EventArgs e)
    {
        if(parameter == "SQL")
        { 
             WebService1 ws = new WebService1();
             ws.deleteTerm(term);
        }
        if(parameter == "DB2")
        { 
             WebServiceDB2 ws = new WebServiceDB2();
             ws.deleteTerm(term);
        } 
    }

As this will double my code and I make web service calls regularly in all pages of the site.

  • 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-18T11:19:20+00:00Added an answer on June 18, 2026 at 11:19 am

    You can extract this check in a method in your project, which takes the parameter for the server as well.

    public void DeleteTerm(string term, string Server)
    {
       if(Server == "SQL")
        { 
             WebService1 ws = new WebService1();
             ws.deleteTerm(term);
        }
        if(Server == "DB2")
        { 
             WebServiceDB2 ws = new WebServiceDB2();
             ws.deleteTerm(term);
        } 
    }
    

    Then later you can call it like:

    protected void deleteButton_Click(object sender, EventArgs e)
    {
        DeleteTerm(term,paramter);//where parameter is your class level variable. 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Web Role that is using the ASP.NET SQL Membership provider. Currently
I'm currently working on web application using VB in ASP.NET. Right now I have
I have an ASP.net WebService which uses a Library, this has a dependency on
I currently have an ASP.Net Web Form that looks like this: Each section of
I have an ASP.NET Webform which currently calls a Java WebService. The ASP.NET Webform
I currently have an Instance of the ASP.net ajax control toolkit combo box residing
In one of the ASP .Net site we are currently working we have a
I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have
I have a project that needs to be done using ASP.NET. Currently, I'm using
I currently have an ASP.NET 3.5 SP1 running on IIS 7. I have enabled

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.