473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to pass an DataSet

Hello!
I have a WebMethod like this

[WebMethod]

public void MakeOrder(DataSet ds)

{

try

{

// insert into order details

foreach (DataRow dr in ds.Tables[0].Rows)

{

cmd = new SqlCommand("OrderDetails_Insert", conn);

cmd.CommandType = CommandType.StoredProcedure;

parms = new SqlParameter[4];

parms[0] = new SqlParameter("@OrderID", SqlDbType.BigInt);

parms[0].Value = 1;

parms[1] = new SqlParameter("@ProductID", SqlDbType.Char, 10);

parms[1].Value = dr["@ProductID"].ToString();

parms[2] = new SqlParameter("@Qty", SqlDbType.Float);

parms[2].Value = Convert.ToSingle(dr["Qty"]);

parms[3] = new SqlParameter("@Price", SqlDbType.Money);

parms[3].Value = Convert.ToSingle(dr["Price"]);

foreach (SqlParameter p in parms)

cmd.Parameters.Add(p);

if (conn.State != ConnectionState.Open)

conn.Open();

cmd.ExecuteNonQuery();

}

}

catch {}

finally

{

conn.Close();

}

}

Then I call this method from my application. Everything seems to be OK. But
when I check my Database (into where the web-method must insert data from
dataset ), I got nothing here.

I wondered if I must call my Web-Method by Value (not be reference), is it
true? If true, so how to do it? Pls help me

Thanks you!

--
Contact:
Bauman Moscow State Technical University
Russia, Moscow 105005
Tel: +7915-426-6272
ICQ: 160-223-078
YM: Chipheo2k
Jun 4 '06 #1
2 1022
"Duong Nguyen" <Du*********@mail.ru> wrote in message
news:e9**************@TK2MSFTNGP03.phx.gbl...
Then I call this method from my application. Everything seems to be OK.
But when I check my Database (into where the web-method must insert data
from dataset ), I got nothing here.


Hi Duong,

check if you are accessing the correct table. If you have multiple tables in
the dataset, the table that you are looking for may be not with index 0.

Regards,

--
Martin Kulov
http://www.codeattest.com/blogs/martin

MVP, MCT, MCSD, MCPD

Jun 5 '06 #2
I think it would be a good idea to check the return value after executing the
Query. Read below for return results.

For UPDATE, INSERT, and DELETE statements, the return value is the number of
rows affected by the command. For all other types of statements, the return
value is -1. If a rollback occurs, the return value is also -1.
"Duong Nguyen" wrote:
Hello!
I have a WebMethod like this

[WebMethod]

public void MakeOrder(DataSet ds)

{

try

{

// insert into order details

foreach (DataRow dr in ds.Tables[0].Rows)

{

cmd = new SqlCommand("OrderDetails_Insert", conn);

cmd.CommandType = CommandType.StoredProcedure;

parms = new SqlParameter[4];

parms[0] = new SqlParameter("@OrderID", SqlDbType.BigInt);

parms[0].Value = 1;

parms[1] = new SqlParameter("@ProductID", SqlDbType.Char, 10);

parms[1].Value = dr["@ProductID"].ToString();

parms[2] = new SqlParameter("@Qty", SqlDbType.Float);

parms[2].Value = Convert.ToSingle(dr["Qty"]);

parms[3] = new SqlParameter("@Price", SqlDbType.Money);

parms[3].Value = Convert.ToSingle(dr["Price"]);

foreach (SqlParameter p in parms)

cmd.Parameters.Add(p);

if (conn.State != ConnectionState.Open)

conn.Open();

cmd.ExecuteNonQuery();

}

}

catch {}

finally

{

conn.Close();

}

}

Then I call this method from my application. Everything seems to be OK. But
when I check my Database (into where the web-method must insert data from
dataset ), I got nothing here.

I wondered if I must call my Web-Method by Value (not be reference), is it
true? If true, so how to do it? Pls help me

Thanks you!

--
Contact:
Bauman Moscow State Technical University
Russia, Moscow 105005
Tel: +7915-426-6272
ICQ: 160-223-078
YM: Chipheo2k

Jun 12 '06 #3

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

Similar topics

4
444
by: Andrew Carlson | last post by:
I have a class that performs a few methods on a dataset. That dataset then fills a grid on a form. What I would like to do is to assign a particular dataset to the class at runtime. For...
1
2912
by: Jonathan Gibbs | last post by:
I'm very new to xml, and struggling a bit.. I want to use an .xsd file passed to a windows application to define a dataset's schema, and also (if possible) pass other metadata associated with...
3
2371
by: Rouven Hertenstein | last post by:
Hi, I'm trying to test the vb.net-exercise "How to use a DataSet with the Office XP Chart Component and ASP.NET" on http://support.microsoft.com/kb/303016/en-us Visual Studio rails against the...
1
7729
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control...
0
1098
by: Scott R | last post by:
I have a data layer that is set up to pass datasets to and from the presentation layer. In migrating to 2.0, I would like to use the objectdatasource. The problem I am having is that it seems...
1
1397
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
1
4469
by: Justin Crossley | last post by:
I'm having a type mismatch problem when trying to pass a typed dataset to a web service. My code is: CLIENT CODE I have a dataset schema file called MainData.xsd containing a table called...
13
2134
by: andrea | last post by:
Sorry for the stupid question, I know, but sometimes is necessary starts from the basic. I don't know how to pass the result of a method generated from a DAL class to a BL class returning the...
5
3035
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over...
3
1305
by: RAB | last post by:
I have filled a dataset with the following code in VB... ...... dim DataSet as System.Data.DataSet = new System.Data.DataSet dataAdapter.Fill (dataSet) dim MyInt as integer I want to...
0
7115
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
7154
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,...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.