新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国XML论坛<<     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> Oracle, SQL Server与XML,XML在数据挖掘中的应用, PMML.
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - 高级XML应用『 XML 与 数据库 』 → 如何将XML文件导出成SQL数据库中的数据? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4489 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 如何将XML文件导出成SQL数据库中的数据? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     init.ora 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:8
      积分:84
      门派:XML.ORG.CN
      注册:2004/9/1

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给init.ora发送一个短消息 把init.ora加入好友 查看init.ora的个人资料 搜索init.ora在『 XML 与 数据库 』的所有贴子 引用回复这个贴子 回复这个贴子 查看init.ora的博客楼主
    发贴心情 如何将XML文件导出成SQL数据库中的数据?

    msdn 里面的內容﹕

    A. Bulk loading XML in a table
    The following script, written in the Microsoft Visual Basic&reg; Scripting Edition (VBScript), loads an XML document into a table.

    set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.2.0")
    objBL.ConnectionString = "provider=SQLOLEDB.1;data source=localhost;database=Northwind;uid=UserName;pwd=UserPassword"
    objBL.ErrorLogFile = "c:\error.log"
    objBL.Execute "SampleSchema.xml", "SampleXMLData.xml"
    set objBL=Nothing

    1.Create this table:
    CREATE TABLE Cust(CustomerID  int PRIMARY KEY,
                           CompanyName varchar(20),
                      City        varchar(20))
    GO

    2。Create a file in Notepad, and save it as SampleSchema.xml. To this file, add the following XSD schema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:sql="urn:schemas-microsoft-com:mapping-schema">

      <xsd:element name="Customers" sql:relation="Cust" >
       <xsd:complexType>
         <xsd:sequence>
           <xsd:element name="CustomerID"  type="xsd:integer" />
           <xsd:element name="CompanyName" type="xsd:string" />
           <xsd:element name="City"        type="xsd:string" />
         </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>

    3.Create a file in Notepad, and save it as SampleXMLData.xml. To this file, add the following XML document:
    <ROOT>
      <Customers>
        <CustomerID>1111</CustomerID>
        <CompanyName>Sean Chai</CompanyName>
        <City>NY</City>
      </Customers>
      <Customers>
        <CustomerID>1112</CustomerID>
        <CompanyName>Tom Johnston</CompanyName>
         <City>LA</City>
      </Customers>
      <Customers>
        <CustomerID>1113</CustomerID>
        <CompanyName>Institute of Art</CompanyName>
      </Customers>
    </ROOT>

    4.Create a file in Notepad, and save it as BLoad.vbs. To this file, add the VBScript code that is provided in this example. Modify the connection string to provide the appropriate server and database name. Specify the appropriate path for the files that are specified as parameters to the Execute method.


    5.Execute the VBScript code. XML Bulk Load loads the XML into the Cust table.

    偶運行出錯如下﹕請指教

    Server Error in '/WebApplication2' Application.
    --------------------------------------------------------------------------------

    Cannot create ActiveX component.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Exception: Cannot create ActiveX component.

    Source Error:


    Line 5:  sub page_load (sender as object, e as eventargs)
    Line 6:  dim objbl
    Line 7:   objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad.2.0")
    Line 8:  objBL.ConnectionString = "provider=SQLOLEDB.1;data source=localhost;database=Northwind;uid=UserName;pwd=UserPassword"
    Line 9:  objBL.ErrorLogFile = "c:\error.log"

    Source File: C:\Inetpub\wwwroot\WebApplication2\test.aspx    Line: 7

    Stack Trace:


    [Exception: Cannot create ActiveX component.]
       Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String ServerName)
       ASP.test_aspx.page_load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication2\test.aspx:7
       System.Web.UI.Control.OnLoad(EventArgs e)
       System.Web.UI.Control.LoadRecursive()
       System.Web.UI.Page.ProcessRequestMain()


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/9/1 11:05:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML 与 数据库 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/2/20 4:01:31

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    8,347.656ms