473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataTable passed to a web service

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 );
}
}
Nov 23 '05 #1
0 1432

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
1
by: cpnet | last post by:
I have a DataTable defined in a strongly-typed DataSet: public class MyDataSet: DataSet... { ... public class MyDataTable: DataTable... { ...}
5
by: Jim Murphy | last post by:
In creating a C# web service, I am having trouble returning a DataTable object as the result of a web method. I have no problem returning native types like string or int, but cannot return a .NET...
9
by: jsoques | last post by:
Hello, I created a Web Service using .Net 2.0 that has a function that returns a DataTable. I can test the function from the web page when I access the .asmx from a browser on localhost and it...
4
by: Joseph Geretz | last post by:
I don't get it. A DataTable can't be returned, but a DataSet can. Yet a DataSet contains one or more DataTables. So obviously a DataTable must be serializable. So why not just let me return a...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: =?Utf-8?B?VG9t?= | last post by:
Folks, I need to send a non-strongly typed DataTable as a parameter through my web service to update the database with the user's changes, and need to return it to the user's client app with any...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.