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.
You can extract this check in a method in your project, which takes the parameter for the server as well.
Then later you can call it like: