Click here to Skip to main content
15,910,878 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to work on BNC POS Printer Pin
Thomas Krojer24-Feb-10 3:18
Thomas Krojer24-Feb-10 3:18 
GeneralRe: How to work on BNC POS Printer Pin
CoderForEver24-Feb-10 8:01
CoderForEver24-Feb-10 8:01 
GeneralRe: How to work on BNC POS Printer Pin
Thomas Krojer25-Feb-10 1:04
Thomas Krojer25-Feb-10 1:04 
GeneralRe: How to work on BNC POS Printer Pin
CoderForEver25-Feb-10 8:46
CoderForEver25-Feb-10 8:46 
Questionrunning a window without installing Pin
Wamuti14-Feb-10 7:16
Wamuti14-Feb-10 7:16 
AnswerRe: running a window without installing Pin
Luc Pattyn14-Feb-10 7:33
sitebuilderLuc Pattyn14-Feb-10 7:33 
GeneralRe: running a window without installing Pin
Wamuti14-Feb-10 7:40
Wamuti14-Feb-10 7:40 
QuestionXml database Pin
antrock10114-Feb-10 6:48
antrock10114-Feb-10 6:48 
this taken from another forum i'm on, however they dont seem to have an answer.It is 2 posts i have put into this 1 post to show the progression.

POST 1

Hello, i'm trying to create an XML database to hold names.

It's for a game based on film making. I have 3 forms 1 main form 1 for naming the film 1 for archives (to view what films you have made in the past)

Basically in the name the film form you add the name into a text box, to avoid using a database orginally as i don't understand them fully i used a list.

NAMING FORM
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Pmanager<br />
{<br />
    public partial class Shoot : Form<br />
    {<br />
        string moviename;<br />
        public List<string> FilmNames = new List<string>();<br />
        <br />
        public Shoot()<br />
        {<br />
            InitializeComponent();<br />
            <br />
        }<br />
<br />
        private void textBox1_TextChanged(object sender, EventArgs e)<br />
        {<br />
            moviename = textBox1.Text;<br />
            <br />
            <br />
        }<br />
<br />
        private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            listmethod();<br />
            foreach (string Item in FilmNames)<br />
            {<br />
                MessageBox.Show(Item + "\r\n"); // put this in to check if the list was storing between forms<br />
            }<br />
            <br />
        }<br />
<br />
        public void listmethod()<br />
        {<br />
            <br />
            FilmNames.Add(moviename);<br />
<br />
        }<br />
    }<br />
}




ARCHIVES
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Pmanager<br />
{<br />
    public partial class Archieves : Form<br />
    {<br />
        Shoot shoot = new Shoot();<br />
        public Archieves()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void Archieves_Load(object sender, EventArgs e)<br />
        {<br />
            <br />
        }<br />
<br />
        private void textBox1_TextChanged(object sender, EventArgs e)<br />
        {<br />
            foreach (string Item in shoot.FilmNames)<br />
            {<br />
                textBox1.Text += Item + "\r\n";<br />
            }<br />
<br />
        }<br />
<br />
      <br />
    }<br />
}



However it became apparent that why i try to view this list in the archives it wont store the data and writes over it because I am recalling it. So I believe I need a database. I chose to use XML as i dont seem to understand sql to well

in my program main I'm creating a new XML database, this works fine. But i'm not really sure how to store the film names from the txtbox input in naming and displaying in archives.

So I'm unsure where to go, documentation I've looked at doesn't really give an indication, so if anyone could help or if there is a way of storing the list between forms it would be much appreciated.
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Windows.Forms;<br />
using System.Xml;<br />
namespace Pmanager<br />
{<br />
    static class Program<br />
    {<br />
        /// <summary><br />
        /// The main entry point for the application.<br />
        /// </summary><br />
        [STAThread]<br />
        static void Main()<br />
        {<br />
            Application.EnableVisualStyles();<br />
            Application.SetCompatibleTextRenderingDefault(false);<br />
            Application.Run(new Main());<br />
            XmlTextWriter xmlWriter = new XmlTextWriter("database.xml", System.Text.Encoding.UTF8);<br />
            xmlWriter.Formatting = Formatting.Indented;<br />
            xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");<br />
            xmlWriter.WriteStartElement("Root");<br />
            xmlWriter.Close();<br />
        }<br />
    }<br />
}




POST 2

Ok so i started working on xml databases and I got one working that both writes and reads, However it will only write or read 1 field and any added fields on top will overwrite the preceding one.I know this is because I am asking it to only write 1 xml string "ID" so i tried to add a list into the equation and now i'm fully stuck.
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Xml;<br />
<br />
namespace WindowsFormsApplication1<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        string ID = ("ID");<br />
<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void Form1_Load(object sender, EventArgs e)<br />
        {<br />
            XmlTextReader reader = new XmlTextReader(Application.StartupPath + @"\\xmldata.xml");<br />
            while (reader.Read())<br />
            {<br />
                switch (reader.NodeType)<br />
                {<br />
                    case XmlNodeType.Text:<br />
                        textBox2.Text = reader.Value;<br />
                        break;<br />
<br />
                }<br />
            }<br />
        }<br />
<br />
        private void button1_Click(object sender, EventArgs e)<br />
        {<br />
            string sStartupPath = Application.StartupPath;<br />
            XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\\xmldata.xml", null);<br />
            objXmlTextWriter.Formatting = Formatting.Indented;<br />
            objXmlTextWriter.WriteStartDocument();<br />
            objXmlTextWriter.WriteStartElement(ID);<br />
            objXmlTextWriter.WriteString(textBox1.Text);<br />
            objXmlTextWriter.WriteEndElement();<br />
            objXmlTextWriter.WriteEndDocument();<br />
            objXmlTextWriter.Flush();<br />
            objXmlTextWriter.Close();<br />
        }<br />
<br />
        private void textBox2_TextChanged(object sender, EventArgs e)<br />
        {<br />
<br />
        }<br />
<br />
    }<br />
}

JokeRe: Xml database Pin
Dan Mos14-Feb-10 7:12
Dan Mos14-Feb-10 7:12 
GeneralRe: Xml database Pin
antrock10114-Feb-10 7:14
antrock10114-Feb-10 7:14 
AnswerRe: Xml database Pin
Dan Mos14-Feb-10 7:23
Dan Mos14-Feb-10 7:23 
GeneralRe: Xml database Pin
antrock10114-Feb-10 7:26
antrock10114-Feb-10 7:26 
GeneralRe: Xml database Pin
Dan Mos14-Feb-10 7:40
Dan Mos14-Feb-10 7:40 
GeneralRe: Xml database Pin
antrock10114-Feb-10 7:50
antrock10114-Feb-10 7:50 
GeneralRe: Xml database Pin
Dan Mos14-Feb-10 7:58
Dan Mos14-Feb-10 7:58 
GeneralRe: Xml database Pin
Not Active14-Feb-10 9:23
mentorNot Active14-Feb-10 9:23 
AnswerRe: Xml database Pin
Keith Barrow14-Feb-10 9:58
professionalKeith Barrow14-Feb-10 9:58 
GeneralRe: Xml database Pin
antrock10114-Feb-10 10:00
antrock10114-Feb-10 10:00 
GeneralRe: Xml database Pin
Keith Barrow14-Feb-10 10:09
professionalKeith Barrow14-Feb-10 10:09 
GeneralRe: Xml database Pin
antrock10114-Feb-10 11:39
antrock10114-Feb-10 11:39 
Questionusing webcam Pin
naghoumeh1414-Feb-10 6:26
naghoumeh1414-Feb-10 6:26 
Questionuse only 2 digis in simple precision Pin
naghoumeh1414-Feb-10 6:21
naghoumeh1414-Feb-10 6:21 
AnswerRe: use only 2 digis in simple precision Pin
Dan Mos14-Feb-10 6:36
Dan Mos14-Feb-10 6:36 
GeneralRe: use only 2 digis in simple precision Pin
Luc Pattyn14-Feb-10 6:59
sitebuilderLuc Pattyn14-Feb-10 6:59 
GeneralRe: use only 2 digis in simple precision Pin
Dan Mos14-Feb-10 7:05
Dan Mos14-Feb-10 7:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.