Hi,
I am trying to stroe data in Isolated Storage, but because of "some reason" it's storing only below value in xml file.
<NewDataSet />
Please find the below code,
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ds = New DataSet()
dt = New DataTable()
' Declare your Columns - for brevity sake I went with the LameO
' constructors, but you can (and should) get more specific
Dim LastName As DataColumn
Dim FirstName As DataColumn
Dim WT As DataColumn
Dim Desc As DataColumn
' Initialize the columns
LastName = New DataColumn(TextBox2.Text)
FirstName = New DataColumn(TextBox1.Text)
WT = New DataColumn("WT")
Desc = New DataColumn("Desc")
' Add them to your DataTable
dt.Columns.Add(LastName)
dt.Columns.Add(FirstName)
dt.Columns.Add(WT)
dt.Columns.Add(Desc)
' Add the DataTable to your DataSet
ds.Tables.Add(dt)
WriteInIS(ds)
End Sub
Friend Function WriteInIS(ByVal ds As DataSet) As DataSet
'Dim isoStore As IsolatedStorageFile
isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or _
IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, Nothing, Nothing)
'This line will create the directory. If directory already exists it will simply be ignore and no exception would be raised
isoStore.CreateDirectory(String.Format("{0}\{1}", FOLDER_PATH, SUB_FOLDER_PATH))
'This block of code will open the file, write the DataSet xml into it and then save.
Using writer =
New StreamWriter(
New IsolatedStorageFileStream(
String.Format("{0}\{1}\{2}", FOLDER_PATH, SUB_FOLDER_PATH, FILE_NAME), FileMode.Create, FileAccess.Write, isoStore))
ds.WriteXml(writer)
'writer.Close()
End Using
End Function
What could be the problem?