Questions tagged [system.data.datatable]
57 questions
0
votes
2 answers
datatable won't load in data
I'm trying to use the datable object to load the results of a sql query. Some queries work and others don't. I have put a trace on the database and I can see the right sql gets through but my aspx page doesn't run properly. As I'm using sharepoint…

user1896017
- 83
- 10
0
votes
1 answer
Comparing two DataTables by specific column in C#
I am fairly new to C#, but I was able to pull in data from an excel document to a datatable and also data from a sql stored procedure into a datatable. Now I need to loop through the excel datatable to find anything that does not match from the sql…

Terry Minton
- 39
- 1
- 8
0
votes
2 answers
Make Reachable Class Out Of DataTable LINQToDataTable()?
Within my code I get instances of needing to convert a query list into table. I use the following method to achieve this:
//Attach query results to DataTables
public DataTable LINQToDataTable(IEnumerable varlist)
{
DataTable…

Martin Sansone - MiOEE
- 4,281
- 1
- 29
- 31
0
votes
2 answers
.net: DataTable setting all non numeric values of data table as NULL
Need help to format datatable in .net, giving code below in vb.net
Dim dt As New DataTable
dt.Columns.Add("a", GetType(System.String))
dt.Columns.Add("b", GetType(System.String))
dt.Rows.Add("N/A", "22")
…

Anil
- 3,722
- 2
- 24
- 49
0
votes
3 answers
C# Best way to remove all datatables apart from one
I want to delete all datatables in a dataset apart from one. I've tried this :-
foreach (DataTable table in DtSet.Tables)
{
if (table.TableName != "tblAccounts")
{
DtSet.Tables.Remove(table);
…

bd528
- 886
- 2
- 11
- 29
0
votes
2 answers
Check occurrence of word appearing in datatable column
I have the data below in a datatable this is example data. I would like get the occurrence of 12,13 in the datatable as normally there would be 10-20 million row in the datatable.
Customer | quantity | Product | Code
1 | 3 | …

Jim Brad
- 383
- 1
- 5
- 12
0
votes
2 answers
Repost (sort of) -- Invalid Cast AGAIN (DataTable Row Summation)
I have the ability to total each column and add the row -- using this block of code :
DataRow totalRow = t.NewRow();
int colCount = 1;
for (int j = 1; j < t.Columns.Count; j++)
{
if (t.Columns[j].ColumnName ==…

scottO
- 95
- 7
0
votes
1 answer
iterate through rows of a specific column in datatable
I want to iterate through the rows of a certain column in my datatable and add the contents of these rows to calculate yhe sum. However I only want the sum of SOME rows NOT just all of the rows. I am using the code below to show me the value of the…

Tendai Mare
- 31
- 1
- 2
- 14
0
votes
2 answers
How to work on a "subset" of a DataTable filtered via LINQ?
Let's say I have a table with a Color column. Color can have various values. I have a C# method that can handle items of a given column at a time. Thus, I would like to :
foreach(colorname in mytable.getDistinctColornames)
…

Skippy Fastol
- 1,745
- 2
- 17
- 32
0
votes
1 answer
Datatable Performance in C#.Net
public DataTable FetchData(string sQuery)
{
DataTable dtable = new DataTable();
using (SqlConnection conn = new SqlConnection(conString))
{
conn.Open();
using (SqlCommand sqlCmd = new SqlCommand(sQuery, conn))
…

C-va
- 2,910
- 4
- 27
- 42
-1
votes
1 answer
multiple insert using datatable or list of objects
I want to make a multiple insert so i will pass set of data , and i don't know which method is better from performance view .
passing a data table or list of objects like this :
- public static int Insert(List reward) //list of
…

Anyname Donotcare
- 11,113
- 66
- 219
- 392
-6
votes
3 answers
How to merge two DataTables like this?
I have two datatables
dtTable1:
Name Id Contact
Gems A1 8888880000
George A2 0000008888
dtTable2:
Col1 Col2 Col3
XXX1 YYY1 ZZZ1
XXX2 YYY2 ZZZ2
XXX3 YYY3 ZZZ3
XXX4 YYY4 ZZZ4
My required DataTable is:
Name …

nitu
- 3
- 4