datatable

DataTable internal index is corrupted

I am working with a .NET WinForms app in C#, running against the 3.5 .NET framework. In this app, I am setting the .Expression member of a DataColumn in a DataTable, like so: DataColumn column = dtData.Columns["TestColumn"]; column.Expression = ["some expression"]; The 2nd line, where I actually set Expression, will sometimes result i...

DataTable to JSON

I recently needed to serialize a datatable to JSON. Where I'm at we're still on .Net 2.0, so I can't use the JSON serializer in .Net 3.5. I figured this must have been done before, so I went looking online and found a number of different options. Some of them depend on an additional library, which I would have a hard time pushing thro...

DAL and BLL in .NET

There is this DAL/BLL design suggestion by Microsoft for ASP.NET (2.0) apps. I know some of the alternatives and I've read related questions here on SO. However I wonder if this proposed solution is worth implementing nowadays, is there a specific downside you know of? I want to develop DAL/BLL components for company-internal use, to ac...

Records with data on multiple rows on a datatable using faces

In JSF is it possible to have a datatable displays records as follows? [Name ][Last Name][Age] 1. John Doe 20 Extra info on record 1 2. John Smith 20 Extra info on record 2 Thank you ...

Returning Rows from a .NET Web Service

I am using a .NET web service as an interface to a database. What is the best way to return rows from this web service? I vaguely remember that .NET 2.0 had issues with returning DataTable objects. Do those issues still exist? Update: Some of the issues in .NET 1.1. Also, I believe that in 2.0 the DataTable is deserialized as a DataSet...

passing a datatable as a field from Oracle to .NET

In a .NET Datatable, the columns are Object types, which can include a datatable as a valid type for a column. So you can create a fairly complex structure: CompanyID (Integer) | CompanyName (String) | OrderRecords (DataTable) --------------------------------------------------------------------------- 1 | Acme Corp. ...

Add ado.net data tables to a blank MDB file

I'm wondering how to add several data tables that I've built in code, to a blank MDB file that ships with my app. I find it easy enough to connect to the MDB file via the OledbConnection object, but then I'm at a loss for an easy way to add my tables to it. There it sits...open...and empty, but what next? I can add my tables to a datas...

How do I convert a DataTable to an IDatareader?

We all know that DataReaders are quicker than DataTables since the a DataReader is used in the construction of a DataTable. Therefore given that I already have a DataTable.... Why would I want to convert it to a DataReader? Well I am creating an internal interface called IDataProvider. This interface is intended to be implemented both ...

What is the .NET DataTable best usecase?

I have three Tables Customers, Jobs, Orders I Also have these tables in the a DataSet, which conforms to the same constraints as those in the Database itself. Originally, my intention was to keep the Data in the DataSet, and create various DataView objects to display this data to the user, and also to perform any required manipulations...

Finding the intersection of two .NET DataTables

Is there a relatively straightforward way to get the intersection of two DataTables in .NET? I can think of the obvious ways (iterating over both tables myself in O(n^2)), but I'd like something a little more elegant if it's available. I suspect there may be an intelligent way that I'm not seeing. Readability and maintainability are i...

DataGridView - DataTable - displaying properties

( .NET 2.0, System.Windows.FormsDataGridView and DataTable ) I have 1 datagrid connected to 1 datatable. That datatable contains 1 column: containing objects of my own type "MyObject". MyObject has a public string property "MyProp". I want to display 1 column in the grid: showing the string values of the property MyProp of the MyObjec...

Adding columns to a DataTable bound to a DataGridView does not update the view

I have a DataTable which is populated from a CSV file then, using a DataGridView the data is edited in memory. As far as I understand the programmatic editing of the data should be done on the DataTable where the user editing is done via. the DataGridView. However when I add columns programmatically to the DataTable, it is not reflected...

Changing column order in DataTable bound to DataGridView does not reflect in the view

When the application is run, the DataGridView is bound to a DataTable. Later I add more columns to the DataTable programmatically and it is reflected in the underlying data - i.e. the column Ordinals are as they should be. However this is not reflected in the DataGridView. Instead columns are appended onto the originally generated set. ...

Convert Dataset to IQueryable<T> or IEnumerable<T>

Since there is no Linq to DB2 yet (c'mon IBM!), and I want to deal with IQueryables or IEnumerables in my code, how would I convert a DataTable to an IQueryable? Or an IEnumerable? I have an interface and a class that matches the columns in the datatable... IQueryable<IMyData> GetAS400Data(..parameters..) { DataSet d = GetData(); ...

Is there a good way to display a DataTable in pure WPF?

Is there a good way to display a DataTable in pure WPF? I'm looking for something similar to System.Windows.Forms.DataGrid, but only for one data table, and in WPF. ...

VC# 2008: Get Table names from DataTable into ComboList / How to merge tables from 2 MDBs ?

My program that I am writing's purpose arose with this issue: There are two users, each user saves to a .MDB file. One user has half the updated / correct information (the other half is outdated) and the other user has half the information (the other half is outdated). User1: 25% + 25% = 50% current information needed the other 50% is ...

Merge Datatable columns

Hi I have two data tables say: Table 1: name age ---- --- Bob 40 Table 2: auto kids ---- ---- 3 3 I want to merge the two tables to get something like name age auto kids --- --- --- ---- Bob 40 3 3 Is this possible? I tried merge but it does not seem to be working, thanks. ...

DataTable and javascript

Is there a way to avoid postbacks with gridview every time a row is added to it? In other words, can I store the DataTable on the client and pass it on to the server control when I am done to save, rather than do postbacks every time the row is added? I searched and searched....all I could find was web services, JSON, and I have a fee...

DataRow Update .NET

Hi, I have a question about the datarow and how I can update it... I have a datatable with two columns, id and name. I do the following: // data table has data at this point.... myTable.Columns.Add("Fri"); foreach(DataRow r in myTable.Rows) { r["Fri"] = 4; } What I am trying to do here is add a new columnm...

How do you return more than one DataTable from a method?

I have class which has a method that needs to return three DataTables. I thought I could use Generics but honestly I've never used them, so I'm trying figure it out. It may not be the right thing here. I have in my class Employee: public List<Employee> GetEmployees() { //calls to other methods in my class; //psuedocode GetDataT...