argus42
asked on
Reading xml into a Dataset for a PDA.
I'm new to .NET and this is my first app but
I keep on getting an error I can't seem to find any help on.
The error reads :
"Could not find resource assembly"
Can anyone help me on this problem and maybe show me a solution?
This is the code :
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
namespace Test4
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Combo Box comboBox1;
DataSet companyDS;
string xmlFileName;
string xsdFileName;
private System.Windows.Forms.TextB ox txtbox;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
companyDS = new DataSet();
// Set file names and create file streams
xmlFileName = "\\My Documents\\Company.xml";
xsdFileName = "\\My Documents\\Company.xsd";
FileStream FsXML = new FileStream(xmlFileName,Fil eMode.Open );
FileStream FsXSD = new FileStream(xsdFileName,Fil eMode.Open );
try
{
// Load the data into the DataSet.
XmlTextReader xtrXML = new XmlTextReader(FsXML);
companyDS.ReadXml(xtrXML);
xtrXML.Close(); <- I get an error here
FsXML.Close();
// Load the schema into the DataSet.
XmlTextReader xtrXSD = new XmlTextReader(FsXSD);
companyDS.ReadXmlSchema(xt rXSD);
xtrXSD.Close();
FsXSD.Close();
// Get a DataTable to conveniently use for binding.
DataTable dt = companyDS.Tables["record"] ;
//Bind the list box to state abreviations.
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "Mines";
//Bind the text box for entering data.
txtbox.DataBindings.Add(ne w Binding("Text",dt,"MineID" ));
//
// TODO: Add any constructor code after InitializeComponent call
//
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Exception ");
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.Combo Box();
this.txtbox = new System.Windows.Forms.TextB ox();
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(8, 40);
this.comboBox1.Size = new System.Drawing.Size(176, 21);
//
// txtbox
//
this.txtbox.Location = new System.Drawing.Point(40, 120);
this.txtbox.Size = new System.Drawing.Size(112, 20);
this.txtbox.Text = "textBox1";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(194, 280);
this.Controls.Add(this.txt box);
this.Controls.Add(this.com boBox1);
this.Text = "READ XML";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
}
}
Many Thanks
I keep on getting an error I can't seem to find any help on.
The error reads :
"Could not find resource assembly"
Can anyone help me on this problem and maybe show me a solution?
This is the code :
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
namespace Test4
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Combo
DataSet companyDS;
string xmlFileName;
string xsdFileName;
private System.Windows.Forms.TextB
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
companyDS = new DataSet();
// Set file names and create file streams
xmlFileName = "\\My Documents\\Company.xml";
xsdFileName = "\\My Documents\\Company.xsd";
FileStream FsXML = new FileStream(xmlFileName,Fil
FileStream FsXSD = new FileStream(xsdFileName,Fil
try
{
// Load the data into the DataSet.
XmlTextReader xtrXML = new XmlTextReader(FsXML);
companyDS.ReadXml(xtrXML);
xtrXML.Close(); <- I get an error here
FsXML.Close();
// Load the schema into the DataSet.
XmlTextReader xtrXSD = new XmlTextReader(FsXSD);
companyDS.ReadXmlSchema(xt
xtrXSD.Close();
FsXSD.Close();
// Get a DataTable to conveniently use for binding.
DataTable dt = companyDS.Tables["record"]
//Bind the list box to state abreviations.
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "Mines";
//Bind the text box for entering data.
txtbox.DataBindings.Add(ne
//
// TODO: Add any constructor code after InitializeComponent call
//
}
catch (Exception e)
{
MessageBox.Show(e.Message,
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.Combo
this.txtbox = new System.Windows.Forms.TextB
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(8, 40);
this.comboBox1.Size = new System.Drawing.Size(176, 21);
//
// txtbox
//
this.txtbox.Location = new System.Drawing.Point(40, 120);
this.txtbox.Size = new System.Drawing.Size(112, 20);
this.txtbox.Text = "textBox1";
//
// Form1
//
this.ClientSize = new System.Drawing.Size(194, 280);
this.Controls.Add(this.txt
this.Controls.Add(this.com
this.Text = "READ XML";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
}
}
Many Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did it again and built the project again.
I get the same error.