datatable

C#: DataTable conversion row-by-row

In my abstract class (C# 3) I'm using a virtual method named GetData() which returns a DataTable. The algorithm of the method is as following: Get SQL query string from the class. Get DataTable from database using above query. Do transformations on DataTable and return it. In the 3rd point, I clone the original DataTable in order to ...

How do I enable choosing a row of a h:dataTable using JSF 2.0?

Hello, I'm starting a small project, using JSF 2.0. I'm having problems right in the start, in the CRUD of the first model implemented. What I want to do is pretty simple: The page has some filters to search, and using ajax, it populates a h:dataTable with the results. The user should now select the line with the result he wants to se...

jquery DataTable - change value of a cell not just display value

Hi i am fairly new to jquery DataTables.Hope someone can help What I want to do is change the value of the data before rendering the table, I used this below "fnRowCallback": function( nRow, aData, iDisplayIndex ) { if ( aData[2] == "0" ){ $('td:eq(1)', nRow).html( '6' );} But I found that although I chang...

not able to use CopyToDataTable in linq for returning dataset

how to return a dataset from linq in .net 3.5? I have seen in some sites that CopyToDataTable method is used but I am not able to use that methos as I cannot find System.data.datatableextensions reference in the ref list. Please help me out. Thanks and regards, veena ...

ASP.NET Conversion of DataRow[] to DataTable

How to get a DataTable from DataRow[] collection ? I tried the following conversion , but it returns null. string ProcessQuery(ref DataRow[] rows) { DataTable _tb = new DataTable(); foreach (DataRow _dr in rows) { _tb.Rows.Add(_dr); }...

DataTable sort test question

I was asked this question recently in a test, which I didn't pass. For the life of me, I couldn't spot what the problem was. It's probably something really obvious as well, but even a colleague of mine couldn't spot it either. The best I could come up with was issues with bottlenecks and naming inconsistencies of parameters! I blame i...

Building a report from a runtime generated datatable

Hi people. I have a datatable with some data I have read from a CSV file (you helped me yesterday with that, thanks). Now, I want to show a report with some columns of that datatable. It would be easier if I could see the fields and select them from the report designer: I'd just have to drag them to the columns. The problem is that thi...

DataReader, DataColumn - Can These Show Me Columns In Schema Such as SomeSchema.SomeColumn?

I have a database table where columns are in multiple schemas. Example: SomeTable SomeSchema.Column1 SomeSchema.Column2 AnotherSchema.ColumnA AnotherSchema.ColumnB I have code using a DataTable.Rows[r][c].ToString() syntax and it looks like only the Column1 or ColumnA part is being returned. I need to get the full name SomeSchema.Co...

query that gets only the records needed to the page using Linq

i want to use Linq's Iquerable that gives me the ' query that gets only the records needed to the page' based on the Page size i have given. i have used this: System.Linq.IQueryable<DataTable> ds = (from m in dttableDetails.TableName select m).Take(page_size).Skip(offset); but it is showing me error. i need the returned type as ...

query that gets only the records needed to the page using Linq- not fetched the record based on page size

i have used this query to fetch the Record of the Datatable based on the Pagesize. IEnumerable<DataRow> query1 = from row in dt.AsEnumerable().Take(page_size).Skip(offset) select row; Datatable boundTable= query1.CopyToDataTable(); first time when it opens the offset will be =0; it gives 10 records, next time i pass the offset a...

Expression in DataTable

Hi, I have this simple code: currentDataTable.Columns.Add("Active", Type.GetType("System.Boolean")); currentDataTable.Columns.Add("Symbol", Type.GetType("System.String")); currentDataTable.PrimaryKey = new DataColumn[] {currentDataTable.Columns[1]}; string FilterExpression = "Symbol = AAA"; DataRow[] existingRows ...

avoid duplicate values in datatable

in my db i have values as True/False/false/true.... i need to get oly the Distinct Values as True and False and not the all values as True & False & false & true... my code: DataTable dv= dt.DefaultView.ToTable(true, col.header); dv.Casesensitive=true; but i got the values as True & False & false. how to avoid both similar value...

Problem creating datatable via code and binding to a datagridview

Hey, I am trying to bind my data table inventorytable to the datagrid viewer.the problem in the code is when it compiles,it says the column"make" does not belong to the table but I make the column in the code as follows: public partial class Form1 : Form { List<Car> listCars = new List<Car>(); DataTable inventorytabl...

Insert C# table data into a SQL Server table

Hi, Is there anyway to insert in bulk a System.Data.DataTable in C# into a SQL Server table using a store procedure and passing this table as parameter? The table won't have a fixed number of records, Thanks ...

Convert DataTable to LINQ: Unable to query multiple fields

Importing a spreadsheet I have filled a DataTable object with that data and returns expected results. Attempting to put this into a format I can easily query to search for problem records I have done the following public void Something(DataTable dt) { var data = from row in dt.AsEnumerable() select row["Order"].ToS...

SelectGroupByInto is not grouping!

Hi people. I'm trying to use this implementation of a DataSetHelper to group a DataSet by a column. What I'm doing is: DataSet ds_tmp = new DataSet(); DataTable dt_tmp; ds_tmp.Tables.Add(data_table_UserTime); dsHelper = new DataSetHelper(ref ds_tmp); dt_tmp = dsHelper.SelectGroupByInto("UniqueUsers", ds_tmp.Tables[0], "User, sum(Time) ...

Surprising performance differences: List.Constains,SortedList.ContainsKey,DataRowCollection.Contains,DataTable.Select, DataTable.FindBy

Originally i wanted to ask for the fastest way to query a Datatable for a special row. I have tested 5 different methods for their performance with a surprising(for me) result. Background: I have created a View in a MS Sql-Server 2005 Database. This view has current a total count of 6318 rows. Because i must check very often if a given...

DataTable.Select using the IN operator

I've never found an elegant way to do this, so I'm wondering what methods other developers prefer (for performance, readability, etc). Is there a way to use the LIKE operator in the DataTable.Select() function, based on the results of a query to another DataTable. For example, in SQL Server, the syntax would be: Select SomeValue From...

How to make C# DataTable filter

Hi all; my datatable; dtData ID | ID2 -------- 1 | 2 1 | 3 dtData.Select("ID = 1"); one more rows; i want row "ID = 1 And ID2 = 3" how to make ? ...

ImportRow vs Merge Speed Question

For my own edification, I decided to test the comparative speeds of DataTable.ImportRow vs DataTable.Merge. I found that DataTable.ImportRow was largely slower than DataTable.Merge. On rare occasion, the two functions had an equal processing time. On even rarer occasions, ImportRow was faster than Merge. Below are my testing results an...