datatable

How to upload data to database with ADO.NET

Hey all, I have a web application that has a requirement to take data from an Excel workbook and load it to the database. I am using ADO.NET 2.0 and need to use DataSet/DataTable/DataAdapter/etc. to perform this task. We also have a requirement of verifying the data before it is uploaded and informing the user if there are any PK/FK/U...

Lightweight readonly alternative to DataTable for storing data from SqlDataReader?

I am suing SqlDataReader to read data from SQL Server. However sometimes I want to cache my data in memory as read only lightweight connection free object. I couldn't find any options for me in the BCL. Do I need to write my own implementation of such container, or are any available? What alternatives do I have for storing data from dat...

C# Microsoft Report from datatable object.

I would like to use the Microsoft Report Viewer component to view a report created from a programatically filled datatable. I have been looking for a while but the only information I can find is for reporting on information from a database. ...

Sorting DataTable-columns

I have a datatable something like this: | Col1 | Col6 | Col3 | Col43 | Col0 | --------------------------------------------------- RowA | 1 | 6 | 54 | 4 | 123 | As you see, the Cols are not sorted by their numbers. That is what I want it to look like after the "magic": | Col0 | Col1 | Col3...

How do I get a DataRow from a row in a DataGridView

I'm using a databound WinForms DataGridView; how do I go from a user selected row in the DGV to the DataRow of the DataTable that is its source? ...

C# Reusing an Adapter to populate other controls

Hello All, I'm using the following code to populate a DataGridView (sqliteAdapter derives from DbDataAdapter): sqliteAdapter.SelectCommand.CommandText = SQLCommand; sqliteConn.Open(); using (DataTable dt = new DataTable()) { sqLiteAdapter.Fill(dt); dataGridRes.DataSource = dt; } The Actual SQLCommand is: SELECT Email NOTNULL...

WPF Data Binding and Data from SQL DataTable - need some ideas.

Hello, i have a lot of some WPF windows. On them i write some code, which binds UI controls and data, something like this: public class AddressWindow { public string AddressID { get; set; } public string Addr1 { get; set; } public string Addr2 { get; set; } public string ZIP { get; set; } ...

Datatable update in different thread (WPF)

Hi, I have a Datatable assigned to a DataGrid in main thread. I am updating the same DataTable from two different thread classes. Although the rows gets updated successfully in DataGrid control, I get following execption: NotSupportedException thrown, with the message saying 'This type of CollectionView does not support chan...

DataTables and custom types

I created a class called CustomData which uses another one called CustomOptions as one of its fields. I want to use the CustomData in a DataTable as values. Here's a short overview (simplified, the fields are private and the accessors public, mostly readonly and the set is done by custom methods); enum CustomDataOptionType { // Some va...

Full text search on a bound DataGridView control

Hello all, I cannot seem to be able to find a way to do a full text search on a databound DataGridView control across the entire breath of its columns and rows. The DataTable and DataView objects seems to force me into searching for specific columns either through Select(), Find(), or FindRows(). Same with the DataGridView control. I ...

Dictionaries in DataTable

Say I have 3 Dictionary<string, string> objects. All 3 have the same key like so: Dic1 Dic2 Dic3 K V K V K V A s A z A i B d B e B u C a C r C o D w D t D p Now, I would want to combine these dictionaries in to one DataTable, the DataTable should look like: A s z i B d e u C a r o D w t p An...

JSF: h:datatable problem

Hi! I have problem with h:datatable tag in JSF. I don't know, why my datatable is not showing on my page. Some advices? Here is my code: <h:dataTable rows="2" var="deb" value="#{debCredTab.rows}"> <h:column> <f:facet name="header"> Debet </...

Varying amount of dictionaries in a DataTable

Earlier I asked a question about merging a known number of dictionaries into 1 single DataTable: http://stackoverflow.com/questions/1831209/dictionaries-in-datatable Darin provided me with a satisfactory solution to the problem at hand. But my problemset has evolved. I can no long be certain of the amount of dictionaries I get supplied. ...

Linq to DataTable without enumerating fields

Hi, i´m trying to query a DataTable object without specifying the fields, like this : var linqdata = from ItemA in ItemData.AsEnumerable() select ItemA but the returning type is System.Data.EnumerableRowCollection<System.Data.DataRow> and I need the following returning type System.Data.EnumerableRowCollection<<object,object>> (...

Need a faster DataGridView bulk edit method

Hello all, This is what I'm currently using to implement a "Check all" feature on a bound DataGridView: int max = ((DataTable)dataGridRes.DataSource).Rows.Count; for (int i = 0; i < max; i++) { if(((DataTable)dataGridRes.DataSource).Rows[i].Field<long>(0) == 0) ((DataTable)dataGridRes.DataSource).Rows[i].SetField(0, 1); } ...

C# data table help

I need some help with make a datatable from sql. Is it someone that can help me please. I'm a Newbie. But I want to make my own datatable from scratch in codebehind and now with the premade that is in Visual Studio. Can someone please help me do this? ...

Creating strongly typed DataTable from CSV file in byte[]

I am developing using C# 3 and .NET 3.5 and have an object where the contents of a CSV file (of an unknown format) are held in a byte[] property. I need to parse this byte[] and create a System.DataTable containing the columns and rows. The problem is creating a System.DataTable where column data types match the data in the CSV. I am c...

Can I use DataTable.Select(filterString) to control the displayed rows in a DataGridView and also use DataGridView.Sort() to control the order they're displayed in?

If I write: myDataGridView.DataSource = myDataTable.Select(fitlerString); myDataGridView.Sort(myDataGridView.Columns[1], ListSortDirection.Ascending) I get an InvalidOperationException with the Message "DataGridView control must be bound to an IBindingList object to be sorted." but I can't find a way to get a Datatable (instead of a D...

Reverse GridView into underlying data

I have a gridview with a boundfield and a templatefield (textbox). I'd like to iterate through the rows of the grid and get the underlying data out, including the data key for the grid rows themselves. Given the following gridview row elements, how would I go about reverse engineering the data? <asp:BoundField HeaderText="Due Date" Dat...

Set data type (xml) for a field in data table, using Visual Studio

Hi I have datatype for a field recently converted to xml from varchar(MAX) in SqlServer DB. I want to set this type for the corresponing field in the data table, but it has no option for xml. Any suggestion ? Thanks using VS 08 and SQL SERVER 08 ...