Saving data from VB .Net (2005) to SQL Server(2005) table

Posted on 2009-12-22
Last Modified: 2013-11-08
Experts, After reading thru a number of sources, I have come up with the below code. But, no matter what I try, it will not save data to my SQL Server table. I do not get any errors. I have very little experience with SQL Server stored procedures.
The data I am sending in an XML string:
    <CallPurpose />
    <CallerID />
    <CallerType />
    <ConMethod />
    <Event>Billing &amp; Sell</Event>

The code I am sending it with from VB .Net(2005)
Dim ms As New IO.MemoryStream
        CallEvents.TableName = "CEvents"
        CallEvents.WriteXml(ms, True)
        ms.Seek(0, IO.SeekOrigin.Begin)
        Dim sr As New IO.StreamReader(ms)
        Dim xmlString As String
        xmlString = sr.ReadToEnd


        Using conn As New SqlClient.SqlConnection(sqlDB)


                Dim cmd As New Data.SqlClient.SqlCommand("uspInsertContact", conn)
                cmd.CommandType = CommandType.StoredProcedure
                Dim p As SqlClient.SqlParameter
                p = cmd.Parameters.AddWithValue("@xmlData", xmlString)
                p.SqlDbType = SqlDbType.Xml

and last, the SQL Server (2005)  stored procedure I am sending to:
Create PROCEDURE uspInsertContact
      @xmlData xml

          (BL_Event_ID, Caller_Contact_dts, Call_Purpose_Global_Cd,
           Caller_Contact_User_ID, Caller_Nm, Caller_Type_Global_Cd,
           Call_Length_Nbr, Contact_Event_User_ID, Entity_ID)
      FROM @xmlData.nodes('/DocumentElements/CEvents') x(d)


Question by:JohnPell
    LVL 75

    Accepted Solution

    >     FROM @xmlData.nodes('/DocumentElements/CEvents') x(d)
    change the above to

         FROM @xmlData.nodes('/DocumentElement/CEvents') x(d)

    Author Comment

    Thanks aneeshattingal, I have smacked myself in the head for missing something so obvious. Appreciate the quick response!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now