|
ok..i guess i solved the table problem..just do not know how to close the xmlfile.reader so it allows me to save at will!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
Alienoiz wrote: just do not know how to close the xmlfile.reader so it allows me to save at will! If you create a reader (or a writer) object, then it needs to be disposed - in the same method where you are creating it.
The simpeler option is to wrap the reader in a using statement.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes i saw something about Using and End Using, but i do not know how to apply in my code : )
modified 7-Jan-19 21:02pm.
|
|
|
|
|
That's why we have documentation, examples and tutorials. The syntax for a using-statement is not complicated.
If you want to modify code, you'll have to learn those things
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i usually learn better with examples..when i apply something here and there i memorize and i know how to do later for other code..i also keep some records of code to use when i need : )
Thats why i started this project by trying the .ini method...i was already familiarized with it : )
..you said for me to change into xml..i did and i already learn a lot of new code ehe
Thanks... at least my gadget is evoluting... i would like to solve the issue about the saving!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
Alienoiz wrote: i usually learn better with examples. We all learn in a similar way, and yes, examples help a lot. That's why the documentation on MSDN contains an example for most classes and methods. It also contains the syntax, which explains which construction the compiler expects.
Alienoiz wrote: when i apply something here and there i memorize and i know how to do later for other code Sorry, but that's not going to work, since the thing you may remember may be required in a slightly different way, or needs to modified a tiny bit, or extended a tiny bit. Get a book, learn basics, and get in the habit of looking up every statement that you don't understand on MSDN.
Alienoiz wrote: Thats why i started this project by trying the .ini method...i was already familiarized with it : ) The problem there would be that initialization files are outdated, and they were never meant as a data-store.
Alienoiz wrote: ..you said for me to change into xml..i did and i already learn a lot of new code ehe Yup, that's true; and you seem willing enough to learn and try.
Alienoiz wrote: i would like to solve the issue about the saving! Type the word "using" as the first word on the line below in your code, and see what happens;
xmlFile = XmlReader.Create(filePath, New XmlReaderSettings()) I'll leave it up to you to figure out where to end the using
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
it is not working..i tried to "end using" before than every "end if" and it is not working in any place ![Frown | :(](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_frown.gif)
modified 7-Jan-19 21:02pm.
|
|
|
|
|
The "end using" is placed usually after the last time (the last line of code) you actually need the object you're using. After the end-using the object is no longer valid. Depending on your code, that may be the last line of the method.
Alienoiz wrote: and it is not working in any place What does "not working" mean? I know you got a message from the compiler, but which one?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) this is my code..!
Private Sub MonthCalendar1_DateChanged(sender As Object, e As DateRangeEventArgs) Handles MonthCalendar1.DateChanged
TextBox1.Text = MonthCalendar1.SelectionRange.Start.ToShortDateString()
Dim folderPath As String = Directory.GetCurrentDirectory()
Dim filePath As String = Path.Combine(folderPath, "MEMOS\Database.xml")
If Not File.Exists(filePath) Then
MessageBox.Show("DataBase not found!")
Else
Dim sav = TextBox1.Text
Dim xmlFile As XmlReader
Using xmlFile = XmlReader.Create(filePath, New XmlReaderSettings())
Dim ds As New DataSet
Dim dv As DataView
ds.ReadXml(xmlFile)
Dim dset = ds.Tables.Count
If dset = 1 Then
dv = New DataView(ds.Tables(0))
dv.Sort = "Date"
Dim index As Integer = dv.Find(sav)
If index = -1 Then
MsgBox("Nothing set for this date!")
Else
ComboBox1.Text = (dv(index)("HOUR").ToString())
ComboBox2.Text = (dv(index)("MINUTES").ToString())
ComboBox3.Text = (dv(index)("AMPM").ToString())
TextBox1.Text = (dv(index)("DATE").ToString())
TextBox2.Text = (dv(index)("PLACE").ToString())
TextBox3.Text = (dv(index)("NAME").ToString())
TextBox4.Text = (dv(index)("PHONE").ToString())
TextBox5.Text = (dv(index)("EMAIL").ToString())
TextBox6.Text = (dv(index)("HEADER").ToString())
TextBox7.Text = (dv(index)("MEMO").ToString())
End If
Return
Else
MessageBox.Show("No MEMOS in DataBase!")
End If
End Using
End If
End Sub
in the lines :
Dim xmlFile As XmlReader
and
Using xmlFile = XmlReader.Create(filePath, New XmlReaderSettings())
the word "xmlFile" is underlined in green and red
modified 7-Jan-19 21:02pm.
|
|
|
|
|
Alienoiz wrote: the word "xmlFile" is underlined in green and red Red means "error", which you already said. Hover your mouse over it, and it will display a message. Alternatively, you look in the error-window.
It may be "Type is not defined". The one on "XmlFile" would say that it hides another variable. And yes, you already declared a variable with that name. What happens if you remove the first declaration?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
it happens that the using function works .. but still is in conflict with the saving :s
!!!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
Alienoiz wrote: it happens that the using function works .. but still is in conflict with the saving :s In that case the file is locked by something else; is there a writer in another procedure? Are you viewing the file in an XML-editor while debugging? For example, if you open the XML file using Word, then Word will lock that file, causing an error if you try to read it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok..i will dig harder..maybe another writer.. ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
modified 7-Jan-19 21:02pm.
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) My gadget is almost done .. i just have this small problem i cannot fix....when reading, the textbox does not shows multiline..it is joinning the text..but when writing, the paragraphs are written well!!
So if is good in the xml, the problem must be with the reading code...this is what i am using for read:
Private Sub MonthCalendar1_DateChanged(sender As Object, e As DateRangeEventArgs) Handles MonthCalendar1.DateChanged
TextBox1.Text = MonthCalendar1.SelectionRange.Start.ToShortDateString()
Dim folderPath As String = Directory.GetCurrentDirectory()
Dim filePath As String = Path.Combine(folderPath, "MEMOS\Database.xml")
If Not File.Exists(filePath) Then
MessageBox.Show("DataBase not found!")
Else
Dim sav = TextBox1.Text
Using xmlFile = XmlReader.Create(filePath, New XmlReaderSettings())
Dim ds As New DataSet
Dim dv As DataView
ds.ReadXml(xmlFile)
Dim dset = ds.Tables.Count
If dset = 1 Then
dv = New DataView(ds.Tables(0))
dv.Sort = "Date"
Dim index As Integer = dv.Find(sav)
If index = -1 Then
MsgBox("Nothing set for this date!")
ComboBox1.Text = "01"
ComboBox2.Text = "00"
ComboBox3.Text = "AM"
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
Else
ComboBox1.Text = (dv(index)("HOUR").ToString())
ComboBox2.Text = (dv(index)("MINUTES").ToString())
ComboBox3.Text = (dv(index)("AMPM").ToString())
TextBox1.Text = (dv(index)("DATE").ToString())
TextBox2.Text = (dv(index)("PLACE").ToString())
TextBox3.Text = (dv(index)("NAME").ToString())
TextBox4.Text = (dv(index)("PHONE").ToString())
TextBox5.Text = (dv(index)("EMAIL").ToString())
TextBox6.Text = (dv(index)("HEADER").ToString())
TextBox7.Text = (dv(index)("MEMO").ToString())
End If
Return
Else
MessageBox.Show("No MEMOS in DataBase!")
End If
End Using
End If
End Sub
any ideas?!!
TY!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
The code you have shown does not join any texts; on reading the contents of a textbox are replaced.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes they are supposed to be replaced...but is joinning the xml text!!!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
I'm not sure what you are seeing, but the assignment-code is not joining anything.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
well i write:
"Hello
World"
and when i read it returns: "HelloWorld"
simple as that..i do not know what is wrong..after writting i check the .xml file and it is written:
"Hello
World"
i do not know why the text is joinning!!!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
That is an observation, and might happen due to other code. Like the way it is written.
textBox1.Text = "Hello";
textBox1.Text = "World";
Means the first value will be overwritten. There is no joining there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
ok leave it..thanks anyway
modified 7-Jan-19 21:02pm.
|
|
|
|
|
..if you look at that text, you'll see it already has three lines of values before you read it. Are you using multi-line textboxes? If not, then only the first line will be displayed.
I'll bet that you are not overwriting those values on save, but appending them. That's where they get joined.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes i am using mutiline textboxes..leave it..TY!
modified 7-Jan-19 21:02pm.
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) this is what i am using for writting:
Dim newPerson As String =
"<MEMOS ID=""" + TextBox1.Text + """>" & Environment.NewLine & " " &
"<DATE>" + TextBox1.Text + "</DATE>" & Environment.NewLine & " " &
"<HOUR>" + ComboBox1.Text + "</HOUR>" & Environment.NewLine & " " &
"<MINUTES>" + ComboBox2.Text + "</MINUTES>" & Environment.NewLine & " " &
"<AMPM>" + ComboBox3.Text + "</AMPM>" & Environment.NewLine & " " &
"<PLACE>" + TextBox2.Text + "</PLACE>" & Environment.NewLine & " " &
"<NAME>" + TextBox3.Text + "</NAME>" & Environment.NewLine & " " &
"<PHONE>" + TextBox4.Text + "</PHONE>" & Environment.NewLine & " " &
"<EMAIL>" + TextBox5.Text + "</EMAIL>" & Environment.NewLine & " " &
"<HEADER>" + TextBox6.Text + "</HEADER>" & Environment.NewLine & " " &
"<MEMO>" + TextBox7.Text + "</MEMO>" & Environment.NewLine & " " &
"</MEMOS>"
Dim xd As New XmlDocument()
xd.Load(filePath)
Dim docFrag As XmlDocumentFragment = xd.CreateDocumentFragment()
docFrag.InnerXml = newPerson
Dim root As XmlNode = xd.DocumentElement
root.AppendChild(docFrag)
xd.Save(filePath)
MessageBox.Show("MEMO SAVED")
End If
modified 7-Jan-19 21:02pm.
|
|
|
|
|
I don't see anything.. aw, wait, did you mean by "join" that it is removing empty space from the string?
If yes, then that is the normal behaviour. Easiest solution is to encode the data, or wrap it in a CDATA structure.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
yes..thats it removing the spaces in the string!!!
modified 7-Jan-19 21:02pm.
|
|
|
|