我有以下代码:
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim cnn As New SqlConnection("Server=test;uid=sa;pwd=1234;database=empatic")
Dim da As New SqlDataAdapter("select * from producte for xml path('producte'), root('Productes')", cnn)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
Dim a As String = ds.Tables(0).Rows(0).Item(0).ToString
Dim x = XDocument.Parse(a)
Dim s = x.ToString()
TextBoxXml.Text = s
End Sub
End Class
此代码显示Frame中SQL文本的内容。我现在想要的是创建另一个按钮,然后在生成包含框架文本中列出的内容的XML文件时单击。
答案 0 :(得分:0)
System.IO.File.WriteAllText("c:\temp\someXml.xml", TextBoxXml.Text)