Results 1 to 2 of 2

Thread: Why Data Isn't being Inserted By XML into Table in the SQL server Database

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Location
    India
    Posts
    9

    Why Data Isn't being Inserted By XML into Table in the SQL server Database

    Hey !!! why data isnt being inserted into Table in the SQL server ..when vb.net code works fine.. here is structure of stored procedure which i have created to inserted data through my vb.net application. I am passing XML data from vb.net application using sqlparamerters.


    CREATE PROCEDURE [dbo].[upproductdetails]

    @dttest XML

    AS

    BEGIN

    SET NOCOUNT ON

    SET XACt_Abort ON



    BEGIN TRANSACTION
    Begin

    Insert into [productdetails](Product_Id, Product_Name, product_Price)
    SELECT

    D.dttest.value('./Product_Id[1]','nvarchar(15)') AS Product_Id,



    D.dttest.value('./Product_Name[1]','nvarchar(15)') AS Product_Name,



    D.dttest.value('./product_Price[1]','nvarchar(15)') AS product_Price

    FROM @dttest.nodes('/DocumentElement/dttest') AS D(dttest)
    END
    SET XACt_Abort OFF
    COMMIT TRANSACTION
    END

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,837

    Re: Why Data Isn't being Inserted By XML into Table in the SQL server Database

    What does the XML look like?

    If I had to guess... you've got a couple things wrong, but it depends on what your XML looks like.

    -tg


    - Also why are you casting your "price" field as nvarchar and not something reasonable like money or decimal?
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width