Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:28:12+00:00 2026-06-17T21:28:12+00:00

I have two tables: tbl_ClassFac: ClassFacNo (Primary Key) ,FacultyID ,ClassID tbl_EmpClassFac: EmpID, (Primary Key)

  • 0

I have two tables:

tbl_ClassFac:
ClassFacNo (Primary Key)
,FacultyID
,ClassID

tbl_EmpClassFac:
EmpID, (Primary Key)
DateImplement, (Primary Key)
ClassFacNo

I want to know all the Employees who are on a specific ClassFacNo. ie. All EmpID with a specific ClassFacNo… What I do is that I first search tbl_EmpClassFac with the EmpID supplied by the user. I store these datarows. Then use the ClassFacNo from these datarows to search through tbl_ClassFac.
The following is my code.

        empRowsCF = ClassFacDS.Tables["EmpClassFac"].Select("EmpID='" + txt_SearchValueCF.Text + "'");
        int maxempRowsCF = empRowsCF.Length;
        if (maxempRowsCF > 0)
        {
            foundempDT = ClassFacDS.Tables["ClassFac"].Clone();
            foreach (DataRow dRow in empRowsCF)
            {
                returnedRowsCF = ClassFacDS.Tables["ClassFac"].Select("ClassFacNo='" + dRow[2].ToString() + "'");
                foundempDT.ImportRow(returnedRowsCF[0]);
            }
        }
        dataGrid_CF.DataSource = null;
        dataGrid_CF.DataSource = foundempDT.DefaultView;

        ***returnedRowsCF = foundempDT.Rows;*** // so NavigateRecordsCF can be used

        NavigateRecordsCF("F");  // function to display data in textboxes (no importance here)

I know the code is not very good but that is all I can think of. If anyone has any suggestions please please tell me. If not tell me how do I copy all the Rows in a datatable to a datarow array ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:28:13+00:00Added an answer on June 17, 2026 at 9:28 pm

    “How to copy all the rows in a datatable to a datarow array?”

    If that helps, use the overload of Select without a parameter

    DataRow[] rows = table.Select();
    

    DataTable.Select()

    Gets an array of all DataRow objects.

    According to the rest of your question: it’s actually not clear what’s the question.

    But i assume you want to filter the first table by a value of a field in the second(related) table. You can use this concise Linq-To-DataSet query:

    var rows = from cfrow in tbl_ClassFac.AsEnumerable()
               join ecfRow in tbl_EmpClassFac.AsEnumerable()
               on cfrow.Field<int>("ClassFacNo") equals ecfRow.Field<int>("ClassFacNo")
               where ecfRow.Field<int>("EmpId") == EmpId
               select cfrow;
    // if you want a new DataTable from the filtered tbl_ClassFac-DataRows:
    var tblResult = rows.CopyToDataTable();
    

    Note that you can get an exception at CopyToDataTable if the sequence of datarows is empty, so the filter didn’t return any rows. You can avoid it in this way:

    var tblResult = rows.Any() ? rows.CopyToDataTable() : tbl_ClassFac.Clone(); // empty table with same columns as source table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two mysql tables: tbl_jobs ( id INTEGER PRIMARY KEY, status ENUM(runnable, running,
I have two tables, tbl_foo and tbl_bar , and I want to join these
I have two tables :- tbl_ticket_categories(id,category_name,site_referer) tbl_tickets(id,title,category_name,site_referer) I have to get all title from
I have two tables. tbl_Invoice tbl_Payment What I want is List of Pending/Partial Invoices
android noob... I have two tables, with a one to many relationship between country_tbl
I have 10 tables in my database(MySQL). two of them is given below tbl_state
I have two tables images2 and image_data So the goal is to have 1
I have two tables 1.Products prod_id prod_name 1 honda 2 hero 3 marcedes 4
I have two tables, lets say table1 and table2 with common columns, id and
I have two tables: table a ida valuea 1 a 2 b 3 c

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.