Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 January 9th, 2004, 11:01 AM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dataset Merge Problem

I'm developing an application using XML Web Reference, SQL Server database, and Visual Studio.net 2003.
I have a web form which users populate with data (or change data) and click a button to save the data to the database. I use a stored procedure to accomplish this and return the dataset back to the page to re-populate the dataset with the corrected data.
My problem is that the data gets saved properly to the database, but does not get "Merged" back into the dataset properly -- the old data persists.
Here's some code from the .asmx file:
    <WebMethod(Description:="This XML Web service updates Employees " _
        & "from a supplied EID")> _
    Public Function UpdateEIDEmp(ByVal iEID As Integer, ByVal iLName As String, _
    ByVal iFName As String, ByVal iJob As String, ByVal iSuper As Integer, _
    ByVal iPhone As String, ByVal iPID As String, ByVal iEndda As String, _
    ByVal iBegda As String, ByVal iuserChange As String, ByVal idtChange As String) As DataSet

        Dim daEIDEmp As SqlDataAdapter
        Dim dsEmp1 As New dsEmp
        Dim workParam As SqlParameter = Nothing

        'set up the stored procedure
        daEIDEmp = _
            New SqlDataAdapter("sp_UpdateEmp", SqlConnection1)
        daEIDEmp.SelectCommand.CommandType = _
            CommandType.StoredProcedure

        'add the EID input parameter
        workParam = New SqlParameter("@EID", _
            System.Data.SqlDbType.Int)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iEID
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@PID", _
            System.Data.SqlDbType.Int)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iPID
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@Name_F", _
            System.Data.SqlDbType.NVarChar, 20)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iFName
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@Name_L", _
            System.Data.SqlDbType.NVarChar, 20)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iLName
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@Job", _
            System.Data.SqlDbType.NVarChar, 20)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iJob
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@Begda", _
            System.Data.SqlDbType.DateTime)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iBegda
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@Endda", _
            System.Data.SqlDbType.DateTime)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iEndda
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@super", _
            System.Data.SqlDbType.Int)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iSuper
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@PhoneLoc", _
            System.Data.SqlDbType.NVarChar, 25)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iPhone
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@userChange", _
            System.Data.SqlDbType.NVarChar, 12)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = iuserChange
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        workParam = New SqlParameter("@dtChange", _
            System.Data.SqlDbType.DateTime)
        workParam.Direction = ParameterDirection.Input
        workParam.Value = idtChange
        daEIDEmp.SelectCommand.Parameters.Add(workParam)

        'run the stored procedure and fill a dataset
        daEIDEmp.Fill(dsEmp1.t_Emp.DataSet, "sp_EmpByEID")
        'daEIDEmp.Fill(dtEmp, "sp_EmpByEID")

        'close the connection
        'conn.Close()

        Return dsEmp1

    End Function

Then, the page from which this function was called:



        DsEmp2.Merge(ws.UpdateEIDEmp(iEID, iLName, iFName, iJob, iSuper, _
        iPhone, iPID, iEndda, iBegda, iuserChange, idtChange))
        DsEmp2.AcceptChanges()



Running debugger, I find that there are 2 tables in the dataset, dsEmp1, generated in the .asmx page. Then, after the merge statement in the calling page, there are 2 tables in the dataset, dsEmp2, when before the merge, there was only one. BTW, they are both copies of the same dataset, dsEmp.

How can I force the dataset in the .asmx into the proper table?

Joe
 
Old January 9th, 2004, 02:46 PM
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind. I found the problem. I was creating another table when I called the "Fill":
daEIDEmp.Fill(dsEmp1, "sp_EmpByEID")
The schema name for the table was "t_Emp". I had used the name of the stored procedure.

Thanks anyway.
Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge Problem prasanta2expert Access VBA 2 April 26th, 2011 03:23 AM
DataSet - Merge Data Tables srish ADO.NET 0 September 8th, 2007 10:04 AM
Problem in merge replication ocaliptoos SQL Server 2000 1 July 27th, 2006 02:53 PM
Dataset Merge then DB Update druid2112 ADO.NET 0 October 4th, 2004 08:44 AM
Merge Replication Problem sowdens SQL Server 2000 0 December 8th, 2003 09:36 AM





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