VB.NET read XSD from embedded resource
-
I'm reading xml from SQL server with VB.net using an XSD schema file. I have the code working fine, but I'd now like to change the code from reading a file on disk to reading the schema from the file as an embedded resource. Here's my code, what do I need to change??
Dim conString As String = "MyConnectionString" Dim strm As Stream Dim strmReader As StreamReader Dim cmd As New SqlXmlCommand(conString) Dim xmlDoc As New XmlDocument Dim strXML As String With cmd .CommandText = "MyXPath" .CommandType = SqlXmlCommandType.XPath .SchemaPath = "C:\MySchemaFile.xsd" '**I want this to be embedded!!** strm = .ExecuteStream End With strmReader = New StreamReader(strm) strXML = strmReader.ReadToEnd xmlDoc.LoadXml(strXML)
Like I said, the above code works fine, but I don't want a physical file location. Thanks!!! -Michael -
I'm reading xml from SQL server with VB.net using an XSD schema file. I have the code working fine, but I'd now like to change the code from reading a file on disk to reading the schema from the file as an embedded resource. Here's my code, what do I need to change??
Dim conString As String = "MyConnectionString" Dim strm As Stream Dim strmReader As StreamReader Dim cmd As New SqlXmlCommand(conString) Dim xmlDoc As New XmlDocument Dim strXML As String With cmd .CommandText = "MyXPath" .CommandType = SqlXmlCommandType.XPath .SchemaPath = "C:\MySchemaFile.xsd" '**I want this to be embedded!!** strm = .ExecuteStream End With strmReader = New StreamReader(strm) strXML = strmReader.ReadToEnd xmlDoc.LoadXml(strXML)
Like I said, the above code works fine, but I don't want a physical file location. Thanks!!! -MichaelHi Michael. There are several articles on CodeProject that could help you. Do an article search on "embedded resource". Here's a link to one article[^] that may be useful.