Thanks for your time.
I am using below code to get xml file from dataset .
where i want to write code
If any data colum value is null then I need output is with empty xml element.
Code:
Public Shared Sub writeSQLQueryToFileAsXML(ByVal query As String, ByVal filename As String)
Dim myConn As New SqlConnection(getConnectionString)
Dim adapter As New SqlDataAdapter adapter.SelectCommand = New SqlCommand(query, myConn)
Dim myDs As New DataSet
adapter.Fill(myDs)
Dim myFs As IO.FileStream = Nothing
'Get a FileStream object
myFs = New IO.FileStream(filename, IO.FileMode.Create) ', IO.FileAccess.Write)
' Apply the WriteXml method to write an XML document
Dim myXmlWriter As New System.Xml.XmlTextWriter _ (myFs, System.Text.Encoding.Unicode)
myDs.DataSetName = "SamoleData"
myDs.Tables(0).TableName = "FormInfo"
myXmlWriter.WriteStartDocument()
myDs.WriteXml(myXmlWriter, XmlWriteMode.WriteSchema)
myXmlWriter.Close()
End Sub
Thanks in advance.
Enter your message below
Sign in or Join us (it's free).