473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with SQLXML bulk load

Hi all,

I am newbie in all the stuff about xml importing into sql server.


What I try to do is simple. It is take an xml file and drop it into a
table. I am using VS2005, SQLXML 4.0 and SQL Server 2000 (I think
there is no problem of compatibility)


When I run my program using the SQLXMLBulkLoad4Class class,
everythings seems to run perfect and there is no errors. But when I
check my DB there isnt any record inserted.


My schema is:


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="table1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ele1" type="xsd:string"/>
<xsd:element name="ele2" type="xsd:string"/>
<xsd:element name="ele3" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


My xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ENGROLE>
<EROLE>
<ele1>dieg01p</ele1>
<ele2>IE01</ele2>
<ele3>IEL01</ele3>
</EROLE>
.
.
.
</ENGROLE>


and my table definition where I try to insert:


CREATE TABLE [dbo].[table1](
[ele1] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ele2] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ele3] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
) ON [PRIMARY]


As you see it is very simple, but I cannot get it work. Can anyone
give a hand?


Thanks!!
Feb 28 '07 #1
5 2100
kenobewan
4,871 Expert 4TB
I see the create table, but there is not connection or insertion into the database.
Feb 28 '07 #2
my code from asp.net to insert is the following:

class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//

try
{
SQLXMLBulkLoad4Class bulkLoad = new SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class();
bulkLoad.ErrorLogFile = @"c:\prxml\error.xml";
bulkLoad.BulkLoad = true;
bulkLoad.KeepIdentity = false;
bulkLoad.XMLFragment = true;
bulkLoad.ConnectionString = "provider=SQLOLEDB;server=server1;database=DB1;uid =user;pwd=pwd;Trust_Connection=True";
bulkLoad.Execute(@"c:\prxml\schema.xml",@"c:\prxml \caciroles_20070206034617.xml");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
Feb 28 '07 #3
kenobewan
4,871 Expert 4TB
Here is an article that may help:
How to import XML into SQL Server with the XML Bulk Load component
Mar 1 '07 #4
Thank you. I already saw it.

I found out what happened. At the was that the fields in the XML file were in capital letter whereas in the schema were in small letter.

When I changed that everything seemed to work perfectly.

:)
Mar 1 '07 #5
This is a good, very simple example that I would like to use to help me learn ASP.Net. I am more interested in bulk loading XML to SQL Server but would like to use this as an example. Not versed in this, how do I execute the code (class Class1)?
Mar 1 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: php newbie | last post by:
Hello, I am trying to load a simple tab-delimited data file to SQL Server. I created a format file to go with it, since the data file differs from the destination table in number of columns. ...
5
by: me | last post by:
I'm also having problems getting the bulk insert to work. I don't know anything about it except what I've gleened from BOL but I'm not seeming to get anywhere...Hopefully there is some little (or...
0
by: Paula DiTallo | last post by:
Hello Techies-- I am reading an XML document with many nested elements. Many of these elements go to such a variety of tables, that I am trying to simply the read of the document by dumping the...
1
by: norm dingle | last post by:
Does anyone know how to get the managed classes for sqlxml loaded? I can not seem to get them to load. Thanks norm
1
by: Hollywood | last post by:
I have the following XSD created in VS.NET 2003: <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="ReferralSchama" targetNamespace="http://test.org/Referral"...
2
by: Joe Gass | last post by:
Hi I have a query that uses for xml auto I'd like to load this into an xmldocument with an xmlreader e.g. Dim xr As XmlReader xmlDoc = New XmlDocument xr = oCom.ExecuteXmlReader If xr.Read...
5
by: Sumanth | last post by:
Hi, I am running into a problem ( only in this particular instance). I insert one row into a table - takes a fraction of a second try to do a bulk load of the same --takes 10 seconds. ...
11
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
4
by: amjad | last post by:
Hi i have dataset which i write as xml file like ds.WriteXmlSchema(XSDFilename); ds.WriteXml(XMLFilename,XmlWriteMode.IgnoreSchema); then i try to load that file into sql using below code...
4
by: vicpada | last post by:
Hi all, I am newbie in all the stuff about xml importing into sql server. What I try to do is simple. It is take an xml file and drop it into a table. I am using VS2005, SQLXML 4.0 and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.