thukralz

Hello Everyone,

I'm reading a calling information from a file

Calling number, Called to, Time Started, Time Ended

050, 060 , 1255, 1350

050, 080, 1050, 1100

050, 060, 1110, 1130

080, 090, 0530, 0610

What is the best way to read this information and store it in arrays so that if I want to find out 050 called what numbers and at what times How can I do that



Re: Visual C# Language How to store the Information in arrays or Map?

theTroll527

I think the best way to do it is to put it into a memory dataset. That was you can do an SQL call on it to get the 050 and nothing else. Would be a lot easier.

theTroll




Re: Visual C# Language How to store the Information in arrays or Map?

Harsimrat

Can you give me an example, this application has no connection to database and it reads the file and gives user the information.



Re: Visual C# Language How to store the Information in arrays or Map?

Rashmi Gopinath

Hi,

You can use a Dictionary object. I'd suggest that you represent the "Calling number" as the "key" and a concatenation of the other values as "value". You can then get the information that you need based on the key.

Thanks,
Rashmi





Re: Visual C# Language How to store the Information in arrays or Map?

theTroll527

This should give you an example of how to do it. Instead of using the static addrows that I did just create a function to add the rows from your datafile.

You can then use the DataRows to get the data out.

theTroll

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataSetExample
{
public partial class Form1 : Form
{
private System.Data.DataSet data;
private System.Data.DataSet workdingData;

public Form1()
{
InitializeComponent();
data = new DataSet("MyData");
}

private void Form1_Load(object sender, EventArgs e)
{
System.Data.DataTable table = new DataTable("CustomerData");
data.Tables.Add(table);
table.Columns.Add("CallingNumber", System.Type.GetType("System.String"));
table.Columns.Add("CalledTo", System.Type.GetType("System.String"));
table.Columns.Add("TimeStarted", System.Type.GetType("System.String"));
table.Columns.Add("TimeEnded", System.Type.GetType("System.String"));

System.Data.DataRow row = table.NewRow();
row["CallingNumber"] = "050";
row["CalledTo"] = "060";
row["TimeStarted"] = "1250";
row["TimeEnded"] = "1303";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "060";
row["CalledTo"] = "050";
row["TimeStarted"] = "0940";
row["TimeEnded"] = "1021";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "093";
row["CalledTo"] = "060";
row["TimeStarted"] = "0703";
row["TimeEnded"] = "0704";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "050";
row["CalledTo"] = "093";
row["TimeStarted"] = "1432";
row["TimeEnded"] = "1408";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "050";
row["CalledTo"] = "102";
row["TimeStarted"] = "1612";
row["TimeEnded"] = "1613";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "060";
row["CalledTo"] = "050";
row["TimeStarted"] = "1732";
row["TimeEnded"] = "1742";
table.Rows.Add(row);

row = table.NewRow();
row["CallingNumber"] = "050";
row["CalledTo"] = "108";
row["TimeStarted"] = "1250";
row["TimeEnded"] = "1504";
table.Rows.Add(row);

DataRow[] rows = table.Select("CallingNumber = '050'");
DataRow row1 = rows[0];
string CallingNumber = (string)row1["CallingNumber"];
string CalledTo = (string)row1["CalledTo"];
string TimeStarted = (string)row1["TimeStarted"];
string TimeEnded = (string)row1["TimeEnded"];
}
}
}