Questions tagged [.net-datatable]

In .NET, DataTable is a class that represents a table of in-memory data. For the jQuery DataTables plugin, please use [jquery-datatables] tag.

Filter by
Sorted by
Tagged with
0 votes
1 answer
470 views

Populate TreeView with arbitrary depth from DataTable

I have a DataTable with id, parent, label columns and want to populate a TreeView with it. I'm new to c# and as far as I understand, there is no ready solution for it, unlike some other languages. So ...
1 vote
0 answers
784 views

DataGridView Undo/Redo Manager in C#

While answering this code review question, I proposed a solution with List<DataTable>. I am trying to encapsulate this data structure into a "...
3 votes
1 answer
1k views

Undo/Redo Functionality in DataGridView c#

I have looked at many topics related to this topic, but I could not find or understand for datagridview table. Finally I made the undo / redo implementation myself using datatable lists. This solution ...
1 vote
1 answer
469 views

Ideal ways for Choosing DataSet or DataTable

Required to know the performance overhead associated with DataSet and DataTable. When it comes choosing which data structure might be good and performance oriented what if single Result Set is ...
5 votes
2 answers
274 views

Building equal number of records list object

I am trying to get equal number of records in both columns, even if that means that first column doesn't fill page to bottom on the second page. The only way I was able to do this was by using a ...
2 votes
1 answer
11k views

Calculating the total of each column and display in footer of gridview in DataTable

I've used this code to get the sum of the values of each column and display in footer. Here, the advantage is that I don't have to look for the column name, just get the count of total number of rows ...
5 votes
1 answer
397 views

Grouping and summing values for food takeout

I have 4 properties which I calculate using LINQ: ...
8 votes
2 answers
59k views

Converting List to a DataTable and/or DataSet Extension Methods

Can someone help me improve this code? I and trying to have a couple extension methods to convert strongly-typed lists to a DataSet and ...
4 votes
2 answers
319 views

Making a list of customers who buy the top N items from a supplier

I have a method that works perfectly well and does what it's supposed to, albeit a little slow (30 - 40 seconds). I would like to be able to speed it up or at least make it more efficient, any ideas ...
2 votes
1 answer
11k views

Performance of WPF datagrid when using DataGridTemplateColumn

I am using DataGrid to show storagehouse occupancy (Occupied-Show Image With a box, Not Occupied-Show Empty Image). In DataGrid I am using ...
6 votes
1 answer
18k views

Using LINQ to perform a LEFT OUTER JOIN in 2 DataTables (Multiples criteria)

I know that exists a lot of solutions about how to create an OUTER JOIN between two DataTables. I created the following code in ...
4 votes
1 answer
1k views

Mapping DataTable to a concrete type

I have an extension that adds values to a class and I was wondering if there was a faster way to do this. Does a for loop execute faster or would a LINQ query do better? ...
0 votes
1 answer
5k views

Search DataTable by column for a specific row

I would like to know if there are ways to make this run faster. Not a big concern right now, but I would like to think long term, it might be important. This is C#, and I can not change the input ...
4 votes
1 answer
658 views

List of classes to datatable

I'm looking for a function to take a list of generic classes, and map it to different layout of datatable. That means, I can't just directly map my class property names and values to grid, I need to ...
0 votes
2 answers
2k views

Pull From Oracle into CSV File

I have written this code in C# to connect to an Oracle Database, omitting the tnsnames.ora file, then place results from a query into a CSV File. Is there more efficient way to do this? (Such as ...
1 vote
1 answer
1k views

Vertical & Horizontal Direction of a DataTable

I wanted to have a DataTable with cells in direction that is top to bottom or bottom to top and left to right or right to left. LR - LEFT to RIGHT RL - RIGHT to LEFT BT - BOTTOM to TOP TB - TOP to ...
4 votes
0 answers
1k views

CSV Data Table Extension

This is my library I wrote from scratch for the .net core that imports and exports CSVs from DataTable objects. I've seen a lot of huge complicated libraries that handle this and a million other ...
2 votes
4 answers
2k views

C# SQL query builder to fill DataTable

I'm trying to optimize my code and in the process of doing that I made a class Query_builder that handles SQL queries. That class has couple of methods: ...
2 votes
2 answers
4k views

Merge two DataTables by adding corresponding entries

I've been looking over internet for a method of combining 2 datatables with exactly the same cells with numbers to add them together, Merge method never help because it just appended the second table. ...
3 votes
3 answers
658 views

Querying employee schedules in a month [closed]

I have this code, this code querying employee schedules in a month, in a work unit. If the List<Employee> count are few, the code works great, but if the <...
4 votes
0 answers
427 views

Cleaning up memory after loading Access DB into a datagrid

I wrote an app that pulls a MS Access DB into a DataTable and then displays it into a WPF datagrid. The dialog window has a search button which calls on a class ...
4 votes
2 answers
6k views

DataTable runtime grouping on user defined criteria

I one of my tools I use the user can define grouping for a DataTable. The criteria are known only at run-time. To achieve this I use a ...
1 vote
1 answer
777 views

Populate DataTable with API results

I am querying an API and populating a C# Datatable with the results, then using a Table Value Parameter to populate a SQL Server table with the results. This is my solution, but it is slow and takes ...
2 votes
1 answer
198 views

Add data to DataTable

I created a class to operate with concrete table and I want to generalize this code to develop more universal class. Here is one method of this class: ...
5 votes
2 answers
400 views

Constructing file paths for each row of a datatable in C#

I need to iterate through a DataTable and columns in each rows and do some data manipulation. Below given is an extract from my code, I use c#.net. I expect maximum rows in datatable will be less ...
2 votes
1 answer
3k views

List<List<string>> vs DataTable

I have an application which uses SQLite. In that database I have several tables that I need to be able to read and update in my application. Often I need to 'cross-reference' these tables to get the ...
3 votes
1 answer
379 views

Repository/persistence-service implementation

I have the following situation: I have... Models like ServerRoom and ServerCabinet ...
48 votes
2 answers
252k views

Converting DataTable to List of class

I am using ExcelDataReader to import an Excel file to a dataset. Example Excel table: ...
4 votes
1 answer
367 views

Return a paged DataTable

Is there a better way to do it and have it be .Net 2.0 compatible? ...
0 votes
1 answer
2k views

How to generate Datarows based on a delimiter in a Datacolumn from a DataTable in C#

In my office, we use a software called Blue Prism, a Robotic Process Automation System. The idea is to allocate tasks for the robots to perform thereby simulating users. The system enables you to use ...
3 votes
1 answer
167 views

Rolling up Invoice Items Matching Certain Criteria

I have a listing of invoice line items that I need to apply some convoluted business logic to. We have another listing of items that I compare the invoice items to and if I find matches, I then need ...
6 votes
4 answers
81k views

Return a list of values from a single column in a DataTable

I have this code that I was asked to maintain, it is a notification system for a third party application event system (a lot more involved than that but for the sake of this question...) The Code ...
6 votes
1 answer
5k views

Joining datatables to create a new datatable

I am joining datatables to create a new datatable: ...
4 votes
1 answer
24k views

SQL server database access helper class

...
6 votes
2 answers
125 views

Calling functions with different variable types

I need to call the function that will get the value of a datatable cell with the ColIndex, either a text (column name) or an integer (...
9 votes
2 answers
2k views

Optimize a generic foreach method that converts Datatable to my object using Reflection

I need to optimize this code block below, this method converts a Datatable object to the Object that I am passing by parameter, in another words, this serializes the object, however I have to run this ...
9 votes
2 answers
4k views

WinForm Calculator

I'm looking to get this cleaned up. ...
5 votes
2 answers
53k views

Better method for updating data table

I have completed an application which gathers specific records and marks them as Collected. As of now, the application runs perfectly and does exactly what I need ...
1 vote
2 answers
9k views

Convert datagridview data to DataTable

I made an algorithm to calculate when the user has to purchase material adjusting the date in which the order has to be made, I'm using datagridviews to make it work, but I was wondering if there is a ...
3 votes
2 answers
55k views

Getting column values from a datatable

Is there a way I can make the code compact and with fewer ifs? ...
3 votes
2 answers
4k views

Divide certain distinct row values into separate columns

This might be difficult for me to describe clearly but I will try anyway. Also note that this is entirely speculative; it might not even be able to run any faster (that is why I am asking). This is ...
4 votes
3 answers
211 views

Classifying rows of data by the number of days to close

DataTable looks like below I would like to simplify this code in a better manner. ...
2 votes
2 answers
11k views

Method for getting the DataTable when having connection ID and the SQL command

I am quite new to C# and to the ASP.NET programming. When maintaining the legacy code, I have found rather terrible implementation of the method that is used on many places to get the ...
1 vote
2 answers
24k views

Remove matched Rows from two Datatable

Here I have two DataTables: dtTotalDateRangeExcludeSundays dtAbsentsLeavesHolidaysWorks Each has 10k+ values, and I need to delete matched rows. ...
5 votes
1 answer
700 views

Optimize code block for LINQ and non LINQ

I have 2 code block to do same a work and have same target create some thing, but I don't know which block is the best (I mean LINQ or non-LINQ)? First of all, can anyone tell me how to optimize on ...
2 votes
1 answer
16k views

Removing columns based on some conditions

This is a follow up to this question. I'm just removing some columns based on some condition as well using the same condition and adding the column values which I am going to remove to another column....
5 votes
2 answers
21k views

Set default value for NULL in datatable

I have the following codes, which I created as extension for datatable in my project. It actually worked. Just wonder if there is any optimization can be made through. Thanks. =) ...
4 votes
1 answer
971 views

Populating DataGrids

I'm building an in house query tool. The main form has a drop down which allows the user to select how they want to find scripts, and a drop down for what server they want to run the query on. There ...
3 votes
1 answer
133 views

Loose coupling, accessing class properties

I'm trying to get a better understanding of decoupling methods. Right now, I have this method: ...
8 votes
3 answers
1k views

Dataset with optional addition to where statement

I am trying to generate a dataset from a query that has a where statement. If the user passes a value additional things need to be added to the ...