.net中的xml用法 [英] xml usage in .net
本文介绍了.net中的xml用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Soap格式的Xml文件,如何在前端读取xml文件并发送到数据库.
(我通过Biz Talk服务器获取xml文件)
I have Xml file in Soap Format ,how to read xml file in frontend And send to database.
(i get xml file via Biz talk sever)
推荐答案
嗨.
我想您想将XML数据库写回(SQL-)Server ??
我正在使用此代码将我的(导出的)xml文件添加回我的数据库.
(这是vb.net ...您必须稍微更改c#的语法:laugh:)
Hi.
I think you want to write a XML-Database to your (SQL-)Server back??
I am using this code to add a my (exported) xml file back to my database.
(It''s vb.net ... you have to change the syntax a little bit for c# :laugh: )
Private Sub cmdXMLImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdXMLImport.Click
Dim dialog As New OpenFileDialog
dialog.InitialDirectory = Application.StartupPath()
dialog.Filter = "XML (*.xml)|*.xml"
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim sqlConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(SQL-CONNECTIONSTRING)
Dim sqlcmd As SqlCommand = New SqlCommand("Select * from yourTABLE", sqlConnection)
sqlConnection.Open()
Dim da As New SqlDataAdapter(sqlcmd)
Dim ds As New DataSet
da.Fill(ds)
Dim dsNew As New DataSet
dsNew.ReadXml(dialog.FileName, XmlReadMode.Auto)
Dim cb As New SqlClient.SqlCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
Try
da.Update(dsNew.Tables(0))
Catch ex As Exception
MessageBox.Show(Convert.ToString(ex))
End Try
sqlConnection.Close()
End If
End Sub
问候,
The.Z
Regards,
The.Z
这篇关于.net中的xml用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文