I have a C# asmx web service that is being called, and I am seeing the results come back on the client, so I know that the code is running to completion without throwing any exceptions. Here is the web service class:
namespace App_WebRole
{
/// <summary>
/// Summary description for SubscriptionStatus
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class SubscriptionStatus : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld()
{
DataSet1 dataSet = new DataSet1();
DataSet1TableAdapters.StatusRequestsTableAdapter statusTableAdapter = new DataSet1TableAdapters.StatusRequestsTableAdapter();
DataSet1.StatusRequestsRow newRow = dataSet.StatusRequests.NewStatusRequestsRow();
newRow.ApplicationID = "Test";
newRow.RequestDate = DateTime.Now;
dataSet.StatusRequests.Rows.Add(newRow);
dataSet.StatusRequests.AcceptChanges();
statusTableAdapter.Update(dataSet);
return "Hello World 2";
}
}
}
I am running this locally on my machine with a local SQL Server Express database, and I do not see any records being inserted in to the appropriate table.
If I change the return value, I do see the changed value in the client. Also, I looked at the web.config file in the local web site directory, and it has the connection string for the local SQL Server Express database.
Actually, to get this working, I switched away from using a DataSet (.xsd) in my application to using LINQ to SQL classes (.dbml) instead. James’ answer may in fact have done the trick, but by the time he posted it, I had already switched it over to the dbml and had it working like a charm.