Click here to Skip to main content
15,894,405 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sending an email message through windows C#... Pin
Heath Stewart31-Dec-04 8:10
protectorHeath Stewart31-Dec-04 8:10 
GeneralRe: Sending an email message through windows C#... Pin
Heath Stewart1-Jan-05 7:06
protectorHeath Stewart1-Jan-05 7:06 
GeneralMicrophone Input Level Indicator Pin
GTWebb31-Dec-04 3:50
GTWebb31-Dec-04 3:50 
GeneralRe: Microphone Input Level Indicator Pin
Heath Stewart31-Dec-04 7:44
protectorHeath Stewart31-Dec-04 7:44 
GeneralRe: Microphone Input Level Indicator Pin
GTWebb2-Jan-05 12:04
GTWebb2-Jan-05 12:04 
GeneralCardinal Splines Pin
thepersonof30-Dec-04 23:59
thepersonof30-Dec-04 23:59 
GeneralRe: Cardinal Splines Pin
Heath Stewart31-Dec-04 7:59
protectorHeath Stewart31-Dec-04 7:59 
Generalload data's from a xml file into a dataset for a single field alone Pin
dhol30-Dec-04 23:59
dhol30-Dec-04 23:59 
Hi


At present The program what it does is reads any xml schem afile and load data's automatically for each fields in a new xml file. (ie, fora field name "company name" datatype-string - ( values stored as john1, john2..etc up to 200)like that.

Now what I need is , to give a meaning full data.
Ie, I have another xml file with same field name " company name" with meaninful data'a upto 200 data's.

Now I want to insert the data's from that xml file( that field "company name" alone) into the new xml field (company name").
Transferring a single field data's into a new xml file .

PLEASE HELP ME TO DO THAT.

:


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Schema;

namespace testdatagenerator
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtSchema;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox txtXml;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Data.DataSet dataSet1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.txtSchema = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.txtXml = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet1 = new System.Data.DataSet();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
this.SuspendLayout();
//
// txtSchema
//
this.txtSchema.Location = new System.Drawing.Point(232, 24);
this.txtSchema.Name = "txtSchema";
this.txtSchema.Size = new System.Drawing.Size(368, 20);
this.txtSchema.TabIndex = 0;
this.txtSchema.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(616, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Browse";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtXml
//
this.txtXml.Location = new System.Drawing.Point(232, 64);
this.txtXml.Name = "txtXml";
this.txtXml.Size = new System.Drawing.Size(368, 20);
this.txtXml.TabIndex = 2;
this.txtXml.Text = "";
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button2.Location = new System.Drawing.Point(616, 64);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 23);
this.button2.TabIndex = 3;
this.button2.Text = "Load";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button3.Location = new System.Drawing.Point(696, 64);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(64, 23);
this.button3.TabIndex = 4;
this.button3.Text = "Save";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.DataSource = this.dataSet1;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 120);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(776, 320);
this.dataGrid1.TabIndex = 5;
//
// dataSet1
//
this.dataSet1.DataSetName = "NewDataSet";
this.dataSet1.Locale = new System.Globalization.CultureInfo("en-US");
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(32, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(184, 23);
this.label1.TabIndex = 6;
this.label1.Text = "Enter the Xml Schema";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(32, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(192, 23);
this.label2.TabIndex = 7;
this.label2.Text = "Enter the Xml file";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(808, 454);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.txtXml);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtSchema);
this.Name = "Form1";
this.Text = "TestDatagenerator";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "select schema file" ;
fdlg.InitialDirectory = @"c:\CDEV\testdatagenerator" ;
fdlg.Filter = "schema files(*.xsd) |*.xsd| all files(*.*) | *.*";
fdlg.FilterIndex = 2 ;
fdlg.RestoreDirectory = true ;
if(fdlg.ShowDialog() == DialogResult.OK)
{
txtSchema.Text = fdlg.FileName ;
}
}

private void button2_Click(object sender, System.EventArgs e)
{
dataSet1.ReadXmlSchema(txtSchema.Text);

foreach (DataTable dTbl in dataSet1.Tables)
{
for(int j = 0; j <= 200; j++)
{
object[] oValues = new object[dTbl.Columns.Count];
int i = 0 ;

foreach (DataColumn dColmn in dTbl.Columns)
{
switch(dColmn.DataType.ToString())

{
case "System.String":
oValues[i] = (string) "Castle Hampers" + j;
break;

case "System.Int32":
oValues[i] = (int) 100 + j;
break;

case "System.DateTime":
oValues[i] = new DateTime(2004,01,30).AddDays(j * 1);
break;

case "System.Decimal":
oValues[i] = new Decimal(10000900.99) + j;
break;

case "System.Int16":
oValues[i] = (short) 32767 - j;
break;

case "System.Int64":
oValues[i] = (long) 400 - j;
break;

case "System.Double":
oValues[i] = (double) 888888 - j;
break;

case "System.Single":
oValues[i] = (float) 4.5f + j;
break;

}

i = i+1;
}

dTbl.Rows.Add(oValues);
}
}
}
private void button3_Click(object sender, System.EventArgs e)
{

dataSet1.WriteXml(txtXml.Text,XmlWriteMode.WriteSchema );
MessageBox.Show("Saved");
}
}
}

santhosh
GeneralRe: load data's from a xml file into a dataset for a single field alone Pin
Heath Stewart31-Dec-04 6:52
protectorHeath Stewart31-Dec-04 6:52 
GeneralRe: load data's from a xml file into a dataset for a single field alone Pin
dhol31-Dec-04 16:58
dhol31-Dec-04 16:58 
GeneralAdding dll to the workspace Pin
Md Saleem Navalur30-Dec-04 23:21
Md Saleem Navalur30-Dec-04 23:21 
GeneralRe: Adding dll to the workspace Pin
Heath Stewart31-Dec-04 6:38
protectorHeath Stewart31-Dec-04 6:38 
GeneralRe: Adding dll to the workspace Pin
Md Saleem Navalur31-Dec-04 21:29
Md Saleem Navalur31-Dec-04 21:29 
GeneralRe: Adding dll to the workspace Pin
Heath Stewart31-Dec-04 22:49
protectorHeath Stewart31-Dec-04 22:49 
Questionhow to lock a method in class Pin
ting66830-Dec-04 22:11
ting66830-Dec-04 22:11 
AnswerRe: how to lock a method in class Pin
Robert Rohde30-Dec-04 22:19
Robert Rohde30-Dec-04 22:19 
AnswerRe: how to lock a method in class Pin
Heath Stewart31-Dec-04 6:26
protectorHeath Stewart31-Dec-04 6:26 
GeneralRe: how to lock a method in class Pin
ting6682-Jan-05 15:13
ting6682-Jan-05 15:13 
GeneralRe: how to lock a method in class Pin
Heath Stewart2-Jan-05 21:18
protectorHeath Stewart2-Jan-05 21:18 
GeneralRe: how to lock a method in class Pin
ting6683-Jan-05 14:49
ting6683-Jan-05 14:49 
GeneralRe: how to lock a method in class Pin
Heath Stewart3-Jan-05 18:47
protectorHeath Stewart3-Jan-05 18:47 
QuestionIs this kind of encapsulation right for the event and delegate? Pin
Salil Khedkar30-Dec-04 20:00
Salil Khedkar30-Dec-04 20:00 
AnswerRe: Is this kind of encapsulation right for the event and delegate? Pin
Heath Stewart30-Dec-04 20:29
protectorHeath Stewart30-Dec-04 20:29 
GeneralRe: Is this kind of encapsulation right for the event and delegate? Pin
Salil Khedkar2-Jan-05 21:26
Salil Khedkar2-Jan-05 21:26 
Generalload values into the dataset form the xml Pin
dhol30-Dec-04 19:11
dhol30-Dec-04 19:11 

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.