datatable

Removing rows from datatable + AcceptChanges

Hi everybody, I have 2 datatables in my ASP.NET application. I loop though both of them, and if I find a match, I delete that particular row from the outer datatable, lik so: For i As Integer = 0 To dtFixedActs.Count - 1 For j As Integer = 0 To dtTotals.Count - 1 If dtFixedActs.Rows(i).Item("Activity...

What is wrong with this auto-generated t-sql query?

I'm having trouble executing a stored proc... I've got C# code that tries to call the stored proc. It looks somewhat like this: DataTable myDataTable = new DataTable(); using (SqlConnection connection = new SqlConnection(myConnectionString)) { SqlCommand selectCommand = new SqlCommand("MyStoredProc", connection); selectCommand...

MVVM binding DataGrid (WPF Toolkit) to DataTable

I use MVVM for my project, the binding that set to DataTable work correctly at first time, but after I have update data on DataTable, it seem don't effect on DataGrid. Anyone know how to solving it? ...

YUI Datatable Width

This may seem like a basic question, but I'm having trouble figuring out how to set the table width to 100% on a YUI datatable. I tried doing #dtContainer { width: 100%; } #dtContainer table { width: 100% } but none of these approaches work. To clarify, I am trying to set the datatable width to 100% when the table is empty ...

How to implement DataTable property with INotifyPropertyChanged

I have created WPF MVVM application, and set WPFToolkit DataGrid binding to DataTable so I want to know how to implement DataTable property to notify changed. Currently my code is like below. public DataTable Test { get { return this.testTable; } set { ... ... base.OnPropertyChanged("Test"); } }...

DataTable.AsEnumerable().Distinct() doesn't work because of primary key column

I want to remove duplicates from my DataTable so I'm using DataTable.AsEnumerable().Distinct(DataRowComparer.Default) but it doesn't do what I need. I think because each duplicate row has it's unique primary key column. How can I do what I need? Write my own DataRowComparer? I don't want - because the default must works. ...

Linq with DataTables vs plain SQL

I'm working on an app that generates reports that are basically standard SQL operations (sum/average on data grouped by A/B where X=Y etc) the parts of the query can be defined by the user at runtime. as implemented, the raw data is in a a DataTable and I "parse" the query parameters into a linq expression (basically query operands map ...

ADO .NET - adding a DataTable to more than one DataSet

I'd like to add a DataTable to more than one DataSet without calling DataTable.Copy(). Simply copying the DataTable doubles the amount of data in memory and causes me to manage its changes. This problem exists because I am implementing a detail tables solution where a detail table can have more than one master. If it helps, consider thi...

DataTable, How to conditionally delete rows

I'm engaged in a C# learning process and it is going well so far. I however just now hit my first "say what?" moment. The DataTable offers random row access to its Rows collection, not only through typical collections behavior, but also through DataTable.Select. However I cannot seem to be able to tie this ability to DataRow.Delete. So ...

[VB] Spreadsheet from DataTable

In my app, I'm downloading a spreadsheet from FTP, moving the data read from the spreadsheet to a DataTable, and, depending on certain conditions, emailing a new spreadsheet (one that contains certain rows from the 1st spreadsheet). My problem is creating the spreadsheet that will be mailed. I can't seem to work out how to add the row f...

C# DataTable.Select() - How do I format the filter criteria?

Hi everyone. this doesn't work DataRow[] mySelectedRows = myDataTable.Select("processed <> True"); myDataTable has a row named processed. I would like to select the rows from this table where processed is not equal to True. Can anyone help? ...

anyway see why I get this "Concurrency Violation" in these few lines of code??? Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

Here is the code, any ideas why I get this error? private SQLiteDataAdapter DA_Webfiles; // Setup connection, fill dataset etc DataTable dt = this.dataSet.Tables["WEBFILES"]; DataRow newRow = dt.NewRow(); newRow["PATH"] = _url; dt.Rows.Add(newRow); this.DA_Webfiles.Update(this.dataSet, "WEBFILES"); // Works to Here newRow["CONTENT_TYP...

Remove duplicates from DataTable and custom IEqualityComparer<DataRow>

How have I to implement IEqualityComparer<DataRow> to remove duplicates rows from a DataTable with next structure: ID primary key, col_1, col_2, col_3, col_4 The default comparer doesn't work because each row has it's own, unique primary key. How to implement IEqualityComparer<DataRow> that will skip primary key and compare only data...

Dynamically Adding Columns to a Databound XamDataGrid

Hello All, One approach I've tried to solve my problem of needing to be able to dynamically add columns to a databound xamDataGrid is to bind to a .NET DataTable. At startup, I hard-code some data into the DataTable. Then I provide a button which, when clicked, is supposed to add a new column and put random numbers in the new column. I ...

Constraint Exception when copying table?

I'm experiencing some weird behavior when trying to modify some DataTable objects. Upon the second call to the subroutine, I get the following error when I to copy the source DataTable to a working set: System.Data.ConstraintException was caught Message="Column 'pk' is constrained to be unique. Value 'path0.tag0' is already...

Comparing and Merging Identical columns of two Datatables

Hi, I have two datatables.There are few identical columns in both of them.Now I need to compare each Identical column's cell in both the datatables and build a third datatable by merging the changes of identical column's cells and also the un-identical columns.Please help me with C# code in doing it. Thanks, Vix ...

What's wrong with this DataTable while SqlBulkCopy-ing from an Entity?

I know the method below isn't meant to work with any Entity, and its use shouldn't be enforced. I found a System.Data.Linq.Table extension method which uses SqlBulkCopy to insert data. I am trying to adapt it to the Entity Framework but it throws a strange exception, while the original works for Linq-To-Sql data classes. I couldn't find...

DataTable Update Problem

Hello, What is the best method for saving thousands of rows and after doing something, updating them. Currently, I use a datatable, filling it, when done inserting by MyDataAdapter.Update(MyDataTable) After doing some change on MyDataTable, I again use MyDataAdapter.Update(MyDataTable) method. Edit: I am sorry for not providing m...

How can I convert a DataTable to an IEnumerable<Dictionary<string, object>>?

I'd like to convert a DataTable to an IEnumerable<> of Dictionary<string, object>. I tried the following LINQ query, from DataRow row in ds.Tables[0].AsEnumerable() let rowDictionary = new Dictionary<string, object>() from DataColumn column in row.Table.Columns.Cast<DataColumn>() select rowDictionary.Add(column.ColumnName, row[column]...

Query a dataTable by large Query String

I have a datatable that i want to query. the query is very large and complicated and it works when i run it in the SQl Server Editor - so i have the query text. i need to query the datatable with this query String. To Translate the query into linq will take years, and also Select() method of DataTable won't handle it. How can i operate...