Hi,
Could any one please tell me as to how you can change the xml datasource location at runtime in VB.NET 2010, where the location of the datasource keeps on changing as well.
We have built an application in vb.net 2010 in which when you save the data it saves it .xml files as well as .xsd files. I have built a crystal report based on the .xml source and .xsd schema.
The problem is when the user is done with their data input and is ready for submission when they click on Submit Work Order it will create a folder based on lets say today's date and time which would be 20110106_083200 and another one lets say 20110106_083500 the .xml file of the save data will be stored in both these folders and my .xml datasource is supposed to come from the latest folder which would be 20110106_083500 in this case. Whatever data is save I'm supposed to redirect it to the latest folder.
I have managed to grab the latest folder, but just can't seem to change the location of my datasource to be displayed in the crystal reports. I know there are similar scenarios out there, and I have gone through them, they are still missing what I need. On another note, there is no login required. My code is as follows:
Private Sub ViewSubData_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dsXMLDataset As New DataSet()
'Dim dirSubData As DirectoryInfo = New DirectoryInfo(cNM_LocalDataFolder)
'dirSubData.GetDirectories.OrderByDescending()
Dim lastHigh As DateTime = New DateTime(1900, 1, 1)
Dim highDir As String
Dim subdir As String = ""
For Each subdir In Directory.GetDirectories(cNM_LocalDataFolder)
Dim dirSubData As DirectoryInfo = New DirectoryInfo(subdir)
Dim created As DateTime = dirSubData.LastWriteTime
If (created > lastHigh) Then
highDir = subdir
lastHigh = created
End If
Next
Dim oRptdoc As New ReportDocument
Try
'dsXMLDataset.ReadXml(subdir & "\" & cNM_LocalDataFileWO & cNM_LocalDataFileExtension)
oRptdoc.Load(cNM_LocalDataFolder & "\rptViewLastSubData.rpt")
crvViewSubData.ReportSource = oRptdoc
oRptdoc.SetDataSource(subdir & "\" & cNM_LocalDataFileWO & cNM_LocalDataFileExtension)
'oRptdoc.Database.Tables(0).SetDataSource(subdir & "\" & cNM_LocalDataFileWO & cNM_LocalDataFileExtension)
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
Finally
End Try
End Sub
Any help would be greatly appreciated.
Thanks,
Adnan.