Load DataSet object with array???

  • 12 years ago

    Hello friends,

                  I am making the project on "process", i have received all process info like ids, names, memory usage etc in different-different array, and now i want to load all this array in to DataSet object so that i can simply create the XML file. Can any body tell me how i can do this, please help me as soon as possible, my final year project submission is very near and i cant move forward just because of this problem.

    thanks in advance.

  • 12 years ago

    Thanks buddy,

    I think i have found the solution, thanks for your rapid reply, i am really greatful to you.

  • 12 years ago

    Hey,

            i am really greatful to you for helping me, and now i want another help,

    this is my code:

    Column = new DataColumn();

    Column.DataType = System.Type.GetType("System.String");/* i think Here must be something else for Time */

    Column.ColumnName = "Proc_STime";

    Column.AutoIncrement = false;

    Column.ReadOnly = false;

    Column.Unique = false;

    Table.Columns.Add(Column);

    Column =
    new DataColumn();

    Column.DataType = System.Type.GetType("System.String");/* i think Here must be something else for Time */

    Column.ColumnName = "Proc_PProcTime";

    Column.AutoIncrement = false;

    Column.ReadOnly = false;Column.Unique = false;

    Table.Columns.Add(Column);

    Column = new DataColumn();

    Column.DataType = System.Type.GetType("System.String");/* i think Here must be something else for Time */

    Column.ColumnName = "Proc_UProcTime";

    Column.AutoIncrement = false;

    Column.ReadOnly = false;

    Column.Unique = false;

    Table.Columns.Add(Column);

     

    Process proc = Process.GetProcessById(m_nProcIDs[i]); /* where m_nProcIDs[i] is int array which contains process ids */

    Row = Table.NewRow();

    Row[
    "Proc_ID"] = m_nProcIDs[i];

    Row["Proc_Name"] = m_strProcessNames[i];

    Row["Proc_Prio"] = proc.BasePriority;

    /*following three lines are creating some problem i dont know what it is coz it is also not giving error over there, but as soon as i take them out of comment, i get window showing " send this prob to microsoft or not" (usually we get in Win XP) */

     Row["Proc_STime"] = (proc.StartTime.GetDateTimeFormats('F', DateTimeFormatInfo.InvariantInfo))[0];

     

    Row["Proc_PProcTime"] = proc.PrivilegedProcessorTime.ToString();

     Row["Proc_UProcTime"] = proc.UserProcessorTime.ToString();

    /* Following lines are working properly */

    Row["Proc_VMem"] = proc.VirtualMemorySize64.ToString();

    Row["Proc_PMem"] = proc.PrivateMemorySize64.ToString();

    Row["Proc_PagedMem"] = proc.PagedMemorySize64.ToString();

    Row["Proc_PagedSysMem"] = proc.PagedSystemMemorySize64.ToString();

    Row["Proc_NPagedSysMem"] = proc.NonpagedSystemMemorySize64.ToString();

     

    Table.Rows.Add(Row);

     

     

     

     

     

    myDataSet =
    new DataSet();

    myDataSet.Tables.Add(Table);

    myDataSet.WriteXml("Proc_Details.xml");

     

     Please Help me out.

  • 12 years ago

    hi try using try catch on your code so that you will know  the error...and get back to me what errors generated by your code

  • 12 years ago

    This is exaption that i am getting, please kindly help me. 

    System.ComponentModel.Win32Exception: Access is denied
       at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
       at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
       at System.Diagnostics.Process.GetProcessTimes()
       at System.Diagnostics.Process.get_PrivilegedProcessorTime()
       at ThreadMonitor.MainAppForm.InitProcessList() in C:\Documents and Settings\g14\Desktop\Project\01-04-08\DiagnosticTools\ThreadMonitor\MainAppForm.cs:line 918

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov