Click here to Skip to main content
15,926,703 members
Home / Discussions / C#
   

C#

 
GeneralRe: A loop in write statement Pin
jablo30-Dec-04 8:48
jablo30-Dec-04 8:48 
GeneralRe: A loop in write statement Pin
Bill Dean30-Dec-04 9:11
Bill Dean30-Dec-04 9:11 
GeneralTerminating ThreadPool Paths Pin
Tristan Rhodes28-Dec-04 2:09
Tristan Rhodes28-Dec-04 2:09 
GeneralRe: Terminating ThreadPool Paths Pin
Guinness4Strength28-Dec-04 8:52
Guinness4Strength28-Dec-04 8:52 
GeneralRe: Terminating ThreadPool Paths Pin
Tristan Rhodes28-Dec-04 13:35
Tristan Rhodes28-Dec-04 13:35 
GeneralDoes anybody have the C# Sorted ListView by Carlos H. Perez Pin
dfsgdsfgdfg28-Dec-04 1:51
dfsgdsfgdfg28-Dec-04 1:51 
GeneralDoes anybody have the C# Sorted ListView by Carlos H. Perez Pin
dfsgdsfgdfg28-Dec-04 1:50
dfsgdsfgdfg28-Dec-04 1:50 
Generalpassing values to a dataset Pin
dhol28-Dec-04 1:01
dhol28-Dec-04 1:01 
Hi I have done a c# program such that , it reads a xml schema and passes values
to the dataset and create a xml file appropriately for their datatypes
( for ex: john for string, 67 for int)
What I have to do is . At present it creates only 1 row (record) in the xml file.
should loop and create atleast 200 records. Also, think of ways where the 200 records
can be different from each other.

Here is the coding which i have done.
please help me to do my requirement

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;
///
/// 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();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
this.SuspendLayout();
//
// txtSchema
//
this.txtSchema.Location = new System.Drawing.Point(88, 24);
this.txtSchema.Name = "txtSchema";
this.txtSchema.Size = new System.Drawing.Size(440, 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(536, 24);
this.button1.Name = "button1";
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(88, 64);
this.txtXml.Name = "txtXml";
this.txtXml.Size = new System.Drawing.Size(440, 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(536, 64);
this.button2.Name = "button2";
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(616, 64);
this.button3.Name = "button3";
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");
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(808, 454);
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)
{
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) "This is string";
break;

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

case "System.DateTime":
oValues[i] = new DateTime(2004,10,12);
break;

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

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

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

case "System.Double":
oValues[i] = (double) 888888888888888;
break;
}
i += 1;
}
dTbl.Rows.Add(oValues);
}
}
private void button3_Click(object sender, System.EventArgs e)
{

dataSet1.WriteXml(txtXml.Text,XmlWriteMode.WriteSchema );
MessageBox.Show("Saved");
}
}
}
GeneralCreating a DataGrid where one record is painted on multiple raows Pin
A.Mohsen28-Dec-04 0:35
A.Mohsen28-Dec-04 0:35 
Generalget key Pin
ABBASI_RA27-Dec-04 21:47
ABBASI_RA27-Dec-04 21:47 
GeneralRe: get key Pin
Stefan Troschuetz28-Dec-04 5:58
Stefan Troschuetz28-Dec-04 5:58 
GeneralRe: get key Pin
Guinness4Strength28-Dec-04 8:12
Guinness4Strength28-Dec-04 8:12 
GeneralCJK problem in the PDF format Pin
DTaV27-Dec-04 21:35
DTaV27-Dec-04 21:35 
General---Delegates Serialization & Remoting-- Pin
Identity Undisclosed27-Dec-04 21:07
Identity Undisclosed27-Dec-04 21:07 
GeneralRe: ---Delegates Serialization & Remoting-- Pin
leppie27-Dec-04 21:53
leppie27-Dec-04 21:53 
GeneralThe "ESC" character Pin
Hercules0127-Dec-04 19:25
Hercules0127-Dec-04 19:25 
GeneralRe: The "ESC" character Pin
Heath Stewart27-Dec-04 19:46
protectorHeath Stewart27-Dec-04 19:46 
GeneralRe: The "ESC" character Pin
Hercules0128-Dec-04 0:58
Hercules0128-Dec-04 0:58 
GeneralFonts and TreeViews Pin
Beringer27-Dec-04 18:56
Beringer27-Dec-04 18:56 
GeneralRe: Fonts and TreeViews Pin
Identity Undisclosed27-Dec-04 19:53
Identity Undisclosed27-Dec-04 19:53 
GeneralRe: Fonts and TreeViews Pin
Beringer27-Dec-04 21:16
Beringer27-Dec-04 21:16 
GeneralRe: Fonts and TreeViews Pin
Identity Undisclosed27-Dec-04 22:44
Identity Undisclosed27-Dec-04 22:44 
GeneralRe: Fonts and TreeViews Pin
Beringer28-Dec-04 3:56
Beringer28-Dec-04 3:56 
Generalimagelist problem Pin
montu337727-Dec-04 17:50
montu337727-Dec-04 17:50 
GeneralRe: imagelist problem Pin
Heath Stewart27-Dec-04 20:47
protectorHeath Stewart27-Dec-04 20:47 

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.