简体   繁体   中英

Bulk Loading XML Into SQL Server 2012 using Visual Studio 2010

I need to figure out how I can bulk load XML into Microsoft SQL Server 2012 using Visual Studio 2010. I have followed the instructions here , but this gets me a long list of errors (included below).

Additionally, I'm not entirely sure what I'm supposed to do with the instructions for #8: "Replace the Main() method with the following code. Update the ConnectionString property and the file path to the schema and data files." Can someone give me a quick rundown, please?

Though I'm not sure it will help, I also added the SQL DB as a data source.

Error 1:

The type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' has no constructors defined C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 15 64 Aztech - Bulk Load

Error 2:

'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' does not contain a definition for 'ConnectionString' and no extension method 'ConnectionString' accepting a first argument of type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' could be found (are you missing a using directive or an assembly reference?) C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 16 23 Aztech - Bulk Load

Error 3:

'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' does not contain a definition for 'ErrorLogFile' and no extension method 'ErrorLogFile' accepting a first argument of type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' could be found (are you missing a using directive or an assembly reference?) C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 17 23 Aztech - Bulk Load

Error 4:

'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' does not contain a definition for 'KeepIdentity' and no extension method 'KeepIdentity' accepting a first argument of type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' could be found (are you missing a using directive or an assembly reference?) C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 18 23 Aztech - Bulk Load

Error 5:

'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' does not contain a definition for 'Execute' and no extension method 'Execute' accepting a first argument of type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' could be found (are you missing a using directive or an assembly reference?) C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 19 23 Aztech - Bulk Load

Error 6:

Interop type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' cannot be embedded. Use the applicable interface instead. C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 15 35 Aztech - Bulk Load

Error 7:

Interop type 'SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class' cannot be embedded. Use the applicable interface instead. C:\\Users\\coopere.COOPERE-PC\\documents\\visual studio 2010\\Projects\\Aztech - Bulk Load\\Aztech - Bulk Load\\Program.cs 15 86 Aztech - Bulk Load

Thanks for your help in advance.

I am working on the same thing except I am using Visual Studio 2012. Use SQLXMLBULKLOADLib.SQLXMLBulkLoad4 instead of SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class it works for me. Everything else in the example should work then. Once you build your application if there are problems in your xsd or xml files you will get runtime COM errors.

The code inside the main method is what performs the bulk load. Your first error is because SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class has no constructor (eg the method which is called when new SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class). The instantiation of the class object should look similar to this:

SQLXMLBULKLOADLib.SQLXMLBulkLoad4 objBL = new SQLXMLBULKLOADLib.SQLXMLBulkLoad4();

As far as the data.xml, schema.xml files go they either need to be in the same folder as the executable file or you need to put the full path. Hope this help let me know if you need any further clarification.

Question for you....Were you able to find the mapping-schema xsd file which the example references. It's not a huge deal but I get a lot of info messages because that file was not included with the Visual Studio xsd files. I've searched everywhere, but was only able to find some old posting of the contents of the file which doesn't have everything in the current bulkload documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM