Skip to main content

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
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: ...
devspider's user avatar
  • 641
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 ...
Roger's user avatar
  • 195
9 votes
2 answers
4k views

WinForm Calculator

I'm looking to get this cleaned up. ...
MrMoose's user avatar
  • 91
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 ...
aaronmallen's user avatar
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 ...
Kevin's user avatar
  • 240
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 (...
Smith's user avatar
  • 277
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 ...
Malachi's user avatar
  • 28.6k
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 ...
MiBol's user avatar
  • 237
6 votes
1 answer
5k views

Joining datatables to create a new datatable

I am joining datatables to create a new datatable: ...
Harshit's user avatar
  • 183
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 ...
Volearix's user avatar
  • 829
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. =) ...
HengChin's user avatar
  • 173
5 votes
2 answers
276 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 ...
Jefferson's user avatar
  • 353
5 votes
2 answers
401 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 ...
blue's user avatar
  • 171
5 votes
1 answer
703 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 ...
user51150's user avatar
5 votes
1 answer
398 views

Grouping and summing values for food takeout

I have 4 properties which I calculate using LINQ: ...
DeMama's user avatar
  • 151
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. ...
SivaRajini's user avatar
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? ...
KyloRen's user avatar
  • 195
4 votes
2 answers
322 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 ...
Lee Morgan's user avatar
4 votes
1 answer
24k views

SQL server database access helper class

...
Rajesh Naik's user avatar
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 ...
aaronmallen's user avatar
4 votes
1 answer
717 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 ...
WynDiesel's user avatar
  • 145
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 ...
t3chb0t's user avatar
  • 44.3k
4 votes
1 answer
368 views

Return a paged DataTable

Is there a better way to do it and have it be .Net 2.0 compatible? ...
Pop's user avatar
  • 387
4 votes
3 answers
17k views

Search datatable faster

I would like to make the search faster as it takes a long time to retrieve the data that I require. Is there a faster method to do this? I have written the code below to allow me to search through a ...
Tp123's user avatar
  • 41
4 votes
1 answer
210 views

JSON data converting to Excel File

I have two sets of data coming in from the front end. One is the table header and the other is the table body. the data is in ...
Jefferson's user avatar
  • 353
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 ...
Andrew Hendrix's user avatar
4 votes
0 answers
432 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 ...
Phexyaa's user avatar
  • 63
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 ...
Gokhan's user avatar
  • 133
3 votes
3 answers
660 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 <...
SIRS's user avatar
  • 143
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? ...
Simsons's user avatar
  • 723
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 ...
Michael McGriff's user avatar
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 ...
St0ffer's user avatar
  • 135
3 votes
1 answer
134 views

Loose coupling, accessing class properties

I'm trying to get a better understanding of decoupling methods. Right now, I have this method: ...
bmay2's user avatar
  • 133
3 votes
1 answer
380 views

Repository/persistence-service implementation

I have the following situation: I have... Models like ServerRoom and ServerCabinet ...
magueste's user avatar
3 votes
1 answer
374 views

Is my base class constructed correctly?

I have tables that use BulkManager to save data to database. I moved common functionality to BulkTableBase. Because creation of ...
theateist's user avatar
  • 263
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 ...
pepr's user avatar
  • 283
2 votes
1 answer
200 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: ...
Gordon Freeman's user avatar
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: ...
Marko Petričević's user avatar
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. ...
Sibongeleni Mdlalose's user avatar
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 ...
user4221591's user avatar
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 ...
Marthe Veldhuis's user avatar
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 ...
Olivarsham's user avatar
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....
SivaRajini's user avatar
2 votes
1 answer
2k views

A faster implementation of AcceptChanges?

So I started wondering why it takes 3.5 seconds to AcceptChanges for one changed record in a large DataTable. I wrote another ...
Victor Zakharov's user avatar
1 vote
1 answer
542 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 ...
Nɪsʜᴀɴᴛʜ ॐ's user avatar
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 ...
MoralesJosue's user avatar
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 ...
good-to-know's user avatar
1 vote
1 answer
2k views

Adding blank rows for every skipped value in a DataTable

So I have a DataTable that returns results within a month to month range when available. However, when I format the return, I need to still show skipped months as ...
KyleMit's user avatar
  • 227
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. ...
Satinder singh's user avatar
1 vote
1 answer
788 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 ...
user2676140's user avatar