Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2003, 10:11 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Execute method of web service, about database?

Hi all

I create s web service, it have a method updateDemo. The method use to update data of dataset.
When it is runed only one row executes successfully. However I added new or modifyed records

But also method here, when it is runed at side client then ok. I don't the reason why. I hope you help. Thank you very much!

 
Old December 2nd, 2003, 10:29 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What is the method doing?
What does the method accept as argument(s)?

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 3rd, 2003, 03:13 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

        public static bool UpdateTable(string strTableName, DataSet ds)
        {
            //
            if(ds == null)
                return false;
            //
            if(ds.GetChanges() == null)
                return true;
            //
            OleDbConnection pConn = OleDbConnection (strCon) ;
            pConn.Open();
            if(pConn != null && pConn.State == ConnectionState.Open)//
            {
                OleDbTransaction dbTrans = null;
                string mySelectQuery = "SELECT * FROM " + strTableName;
                try
                {

                    dbTrans = pConn.BeginTransaction(IsolationLevel.ReadCommitte d);
                    OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
                    //
                    myDataAdapter.RowUpdating += new OleDbRowUpdatingEventHandler(OnRowUpdating);
                    myDataAdapter.RowUpdated += new OleDbRowUpdatedEventHandler(OnRowUpdated);

                    myDataAdapter.SelectCommand = new OleDbCommand(mySelectQuery, pConn, dbTrans);
                    OleDbCommandBuilder myCommandBuilder = new OleDbCommandBuilder(myDataAdapter);
                    //
                    int k = myDataAdapter.Update(ds,strTableName);
                    //
                    if((dbTrans != null) && (dbTrans.Connection != null))
                        dbTrans.Commit();
                    if(myCommandBuilder != null)
                        myCommandBuilder.Dispose();
                    if(myDataAdapter != null)
                        myDataAdapter.Dispose();
                    //
                    foreach(DataRow dr in ds.Tables[strTableName].Rows)
                    {
                        if(dr.HasErrors)
                            continue;
                        else
                            dr.AcceptChanges();
                    }
                    DisConnectDB(pConn);//Function disconnect
                    return true;
                }
                catch(Exception myException)
                {
                    if((dbTrans != null) && (dbTrans.Connection != null))
                        dbTrans.Rollback();
                    MsgError = myException.Message.ToString();//return a message error
                    DisConnectDB(pConn);//Function disconnect
                    return false;
                }
            }
            return false;
        }
 
Old December 3rd, 2003, 03:18 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Calling from service:
        [WebMethod]
        public bool updateDemo(DataSet ds, string strTableName)//
        {
            //DataSet
            bool b = clsData.UpdateTable(strTableName,ds);
            return b;
        }






Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute Scalar method bmains ADO.NET 2 October 11th, 2008 11:41 PM
c# web service execute remote command? chintu926 .NET Web Services 1 May 24th, 2006 07:05 AM
Hoe Can I Execute an exe file in my web service? ROnak Classic ASP Basics 1 September 14th, 2004 12:09 AM
About method of class in Web Service hueduongit .NET Web Services 5 December 11th, 2003 09:09 PM
Object as parameter in a web service method evandro.paula .NET Web Services 3 October 14th, 2003 02:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.