I'm a newbie to .Net and web serivces. Can you explain how I pass a
DataTable to a web service from a C# application? I've created several web
services and they work great as long as I pass strings, decimals, etc. but
when I try to pass a DataTable or a DataRow array, I receive an error when I
try to execute. What am I doing wrong (see code below)?
[WebMethod]
//public void SaveCycleCountDtls(string InPhysCountDtlID,decimal
PhysQty,string dbName)
public void SaveCycleCountDtls(string BatchID, string CurrentWhseClerk,
DataTable CycleCountdt, string DataBaseName)
{
try
{
this.ConnString += ";Database="+DataBaseName+";";
string INPhysCountDtlID = string.Empty;
Decimal PhysQty = 0;
//Defines the filter expression
string strExpr = "BatchName is not null";
// Sort descending by column named CompanyName.
string strSort = "SeqNo DESC";
// Use the Select method to find all rows matching the filter.
DataRow [] CycleCountdr;
//Get the latest details from data Table
CycleCountdr = CycleCountdt.Select(strExpr, strSort,
DataViewRowState.ModifiedOriginal);
//Loop through the data row and make sure I get the changed rows before
proceding
for(int x=0; x<=CycleCountdr.Length; x++)
{
INPhysCountDtlID = CycleCountdr[x]["InPhysCountDtlID"].ToString();
PhysQty =
Convert.ToDecimal(CycleCountdr[x]["InPhysCountDtlID"].ToString());
SqlParameter paramInPhysCountDtlID = new
SqlParameter("@InPhysCountDtlID",INPhysCountDtlID) ;
SqlParameter paramPhysQty = new SqlParameter("@PhysQty",PhysQty);
int retVal=SqlHelper.ExecuteNonQuery( ConnString,
CommandType.StoredProcedure,
"p_ADCSaveINPhysCountDtl",
paramInPhysCountDtlID,
paramPhysQty);
}
}
catch( Exception ex )
{
throw new Exception( ex.StackTrace );
}
}