locked
sqlxml bulk load RRS feed

  • Question

  • hi i am having trouble using the sqlxml bulk load.

    my xml file is

    <ROOT>
      <marker>
        <address>7416 Beverly Blvd, Los Angeles, CA 90036</address>
        <name></name>
        <loading_zone>Y</loading_zone>
        <picture>4335</picture>
        <lat>34.07616</lat>
        <lng>-118.35179</lng>
        <type>yellow</type>
      </marker>
      <marker>
        <address>7450 Beverly Blvd, Los Angeles, CA 90036</address>
        <name>Café Capo</name>
        <loading_zone>Y</loading_zone>
        <picture>4334</picture>
        <lat>34.07596</lat>
        <lng>-118.35274</lng>
        <type>white</type>
      </marker>
      <marker>
        <address>7615 Beverly Blvd, Los Angeles, CA 90036</address>
        <name>Terroni</name>
        <loading_zone>Y</loading_zone>
        <picture>4323</picture>
        <lat>34.07612</lat>
        <lng>-118.35593</lng>
        <type>white</type>
      </marker>
      <marker>
        <address>7667 Beverly Blvd, Los Angeles, CA 90036</address>
        <name></name>
        <loading_zone>Y</loading_zone>
        <picture>4324</picture>
        <lat>34.07638</lat>
        <lng>-118.35702</lng>
        <type>white</type>
      </marker>
    </ROOT>

    my xsd schema

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
      <xsd:element name="ROOT" sql:is-constant="true">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="marker" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="marker" sql:relation="beverly_blvd">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="id" type="xsd:string"
                sql:datatype="int" />
            <xsd:element name="address" type="xsd:string"
                sql:datatype="nvarchar(MAX)" />
            <xsd:element name="name" type="xsd:string"
                sql:datatype="nvarchar(MAX)" />
            <xsd:element name="loading_zone"
                type="xsd:string"
                sql:datatype="nvarchar(50)" />
            <xsd:element name="picture" type="xsd:string"
                sql:datatype="int" />
            <xsd:element name="lat" type="xsd:string"
                sql:datatype="float" />
            <xsd:element name="lng" type="xsd:string"
                sql:datatype="float" />
            <xsd:element name="type" type="xsd:string"
                sql:datatype="nvarchar(50)" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>


    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Xml;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Configuration;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Collections;
    using SQLXMLBULKLOADLib;
    using System.Data.OleDb;
    using System.Diagnostics;

    namespace BulkLoad
    {
        class Program
        {
            [STAThread]
            static void Main(string[] args)
            {
                string oledbConnectString = "Provider=SQLOLEDB;Data Source=(local);" +
                    "Initial Catalog=MapData;Integrated security=SSPI;";
                string dataFileName = @"..\..\..\beverly_blvd.xml";
                string schemaFileName = @"..\..\..\beverly_blvd.xsd";
                string errorLogFileName = @"..\..\..\BulkLoadError.log";

                SQLXMLBulkLoad4Class bl = new SQLXMLBulkLoad4Class();
                bl.ConnectionString = oledbConnectString;
                bl.ErrorLogFile = errorLogFileName;
                bl.KeepIdentity = false;

                Console.WriteLine("[{0}] Starting bulk load.", DateTime.Now);
                try
                {
                    bl.Execute(schemaFileName, dataFileName);
                    Console.WriteLine("[{0}] Bulk load completed.", DateTime.Now);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[{0}] Error: {1}", DateTime.Now, ex.Message);
                }

                Console.WriteLine(" Press any key to continue.");
                Console.ReadKey();
            }
        }
    }

    i am very new to using the bulk load and i am not sure if i have written it correctly. can someone help me?
    • Moved by liurong luo Wednesday, April 15, 2009 2:05 AM not a Visual Studio Debugger issue.
    Monday, April 13, 2009 6:24 PM

Answers