Member 14814939 Ответов: 0

MS SQL: импорт XML-данных, хранящихся в zip-файле, когда имя файла часто меняется


I am in need of a way to import XML files that may contain data spanning multiple tables in a single database (MS SQL 2014). The files are received in a Zip file and stored in a folder on a cloud storage location (i.e. OneDrive, GoogleDrive, Dropbox, and so forth). The file names are constantly different as part of the name contains the current date and time (i.e. MyDataSite1-27APR2020_081507.ZIP). I have read several articles out here but, sadly, I am new to dealing with XML files and importing data into SQL via XML files. I have written several Visual Basic 2017 / 2019 programs; not that I need to use VB at all. My goal is to write a service that looks in a folder to see if there are any ZIP files to be processed. If there are files to be processed, then insert the data from the XML file(s) contained in each ZIP file from oldest ZIP file to latest ZIP file. The XML files are fully formatted meaning that they contain the table and field data for data going into a single destination MS SQL database. Though I have been programming for a good many year, I have sadly not needed to deal with XML files until now; besides, I have been tasked to start working on this as soon as I can. Thank you greatly for whatever you help with.

Что я уже пробовал:

Я еще ничего не пробовал.

Richard MacCutchan

Не совсем понятно, в чем ваша проблема. Вы можете получить список файлов в папке с помощью Directory класс. Вы можете извлечь все элементы из zip-файла с помощью System.IO.Compression занятия. И вы можете читать XML-файлы через System.XML занятия. Как только у вас будут данные из отдельных XML-файлов, вы сможете разместить их в своей базе данных.

Member 14814939

Richard, It is not so much as being a problem. My concern is my own lack of knowledge of dealing with XML files; hence, reading them and writing the data into the existing tables in my SQL database. I have found much code online; however, a fair share of the examples are from many years ago. I am not saying that the code is unusable in the current time but instead I am saying that there may be some current code examples online somewhere that I could use to get this task completed in a timely manner. Again, my lack of knowledge in this particular area of reading XML files and inserting the data into the SQL database is a problem of mine and I am asking for some guidance. Thanks again.

Richard MacCutchan

Видеть XML-документы и данные | Microsoft Docs[^]. Вы можете использовать Google для поиска статей о конкретных классах или методах классов, упомянутых в этом документе.

0 Ответов