datatable

Check for changes to a SQL table?

How can I monitor a MSSQL database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is .Net and C# (edits) I'd like to support MS SQL 2000 SP4 or higher by "changes to a table" I mean changes to table data, not changes to table structure. Ultima...

Datatable vs Dataset

I current use a datatable to get results from a database which I can use in my code. However, many example on the web show using a dataset instead and accessing the tables through the collections method. Is there any advantage, performance wise or otherwise, of using datasets or datatables as a storage method for sql results?...

Datatables, Dataviews and distincts! (ASP.Net/VB)

Has anyone got anything better than creating a copy of the original datatable and then looping through it to create a distinct view ? From what I've read and attempted, the dataview doesn't support distinct (currently system is in Studio.NET 2003 - looking to move to 2005 shortly but 2008 isn't on the radar - so if newer versions do, pl...

.Net - Returning DataTables in WCF

I have a WCF service from which I want to return a DataTable. I know that this is often a highly debated topic, as far as whether or not returning DataTables is a good practice. Let's put that aside for a moment. When I create a DataTable from scratch, as below, there are no problems whatsoever. The table is created, populated, and r...

DataTable to readable text string

This might be a bit on the silly side of things but I need to send the contents of a DataTable (unknown columns, unknown contents) via a text e-mail. Basic idea is to loop over rows and columns and output all cell contents into a StringBuilder using .ToString(). Formatting is a big issue though. Any tips/ideas on how to make this look ...

Trigger update on DataTable bound to DataGridView

In my .NET/Forms app I have a DataGridView which is bound to a DataTable. The user selects a row of the DataGridView by double-clicking and does some interaction with the app. After that the content of the row is updated programmatically. When the user selects a new row the changes on the previous one are automagically propagated to the...

How many DataTable objects should I use in my C# app?

Hi all, I'm an experienced programmer in a legacy (yet object oriented) development tool and making the switch to C#/.Net. I'm writing a small single user app using SQL server CE 3.5. I've read the conceptual DataSet and related doc and my code works. Now I want to make sure that I'm doing it "right", get some feedback from experienced...

How do I bind the result of DataTable.Select() to a ListBox control?

I have the following code: ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match") ListBox.DisplayMember = "name" The DataTable.Select() method returns an array of System.Data.DataRow objects. No matter what I specify in the ListBox.DisplayMember property, all I see is the ListBox with the correct number of ...

Speed of DataSet row/column lookups?

Recently I had to do some very processing heavy stuff with data stored in a DataSet. It was heavy enough that I ended up using a tool to help identify some bottlenecks in my code. When I was analyzing the bottlenecks, I noticed that although DataSet lookups were not terribly slow (they weren't the bottleneck), it was slower than I expect...

Abstracting storage data structures within XPath

I have a collection of data stored in XDocuments and DataTables, and I'd like to address both as a single unified data space with XPath queries. So, for example, "/Root/Tables/Orders/FirstName" would fetch the value of the Firstname column in every row of the DataTable named "Orders". Is there a way to do this without copying all of th...

DataGridView's bound table only generates one RowChanged event on a double-click. How do I make it do two?

I have a DataGridView whose DataSource is a DataTable. This DataTable has a boolean column, which is interpreted as a checkbox in the DataGridView. employeeSelectionTable.Columns.Add("IsSelected", typeof(bool)); ... employeeSelectionTable.RowChanged += selectionTableRowChanged; dataGridViewSelectedEmployees.DataSource = employeeSelectio...

How can I make a globally accessible datatable in a Winforms application?

Disclaimer: I am new to Winforms. I need to declare a datatable that I can load with data when the main form loads. I then want to be able to reference the datatable from within events like when a button is clicked etc. Where/how should I declare this? ...

Cast or convert when retrieving data from a database?

When accessing an object in a DataTable retrieved from a database, are there any reasons not to cast the object into your desired type, or are there reasons to use convert? I know the rule is cast when we know what data type we're working with, and convert when attempting to change the data type to something it isn't. Presuming we know w...

.NET Fastest way to iterate through rows in a datatable?

Which is generally fastest when reading/comparing row info from a DataTable? 'assume dt as datatable' 'method 1' dim i as int32 for i = 0 to dt.rows.count - 1 .... next 'method 2' dim row as datarow for each row in dt.rows .... next And if there's a difference, in what circumstances does it pay to use one over the other? Th...

DataTable + DataGrid Data Binding Performance Againsts Custom Data Source Object + Data Grid

In our industrial automation application, we need to capture and display the data in the milliseconds. We have data binding between data grid control and a DataTable object. We have around three hundred records which needs to be display in the grid. So we update the 300 records every time we get the records. Example TabularVi...

Getting Count from Grouped DataTable in VB via Linq

I'm running into a mental roadblock here and I'm hoping that I'm missing something obvious. Anyway, assume I have a table that looks like this: ID LookupValue SortOrder ============================================ 1 A 1000 2 B 2000 3 B ...

How do I display only certain columns from a data table?

Hi guys... I'm using a web service that returns a dataset. in this dataset there are 5 table, let's say table A, B, C, D, E. I use table A. So DataTable dt = new DataTable() dt = dataset.Table["A"] Now in this datatable there are columns a1,a2,a3,a4,a5,a6,a7. Let's say I only want to get columns a3 and a4 then bind it to my datagr...

How do you convert a DataTable into a generic list?

Currently, I'm using: DataTable dt = CreateDataTableInSomeWay(); List<DataRow> list = new List<DataRow>(); foreach (DataRow dr in dt.Rows) { list.Add(dr); } Is there a better/magic way? ...

"Endless scrolling" effect in a HTML table

I am displaying a scrolled data table in a web page. This table has several thousands of dynamic rows, so it is loaded from the server (via AJAX). The user can scroll up and down, so what I need is to detect when the user reaches the end of the scrollbar (that is, the last row at the bottom of the table) in order to request and show mo...

OOP and DataTables for Rank Amateurs

I'm a total amateur writing a small App to track to changes in folders. I imagine I'll be keeping information about the directories to watch in one datatable bound to a gridview, when the user clicks a button, the program will create FileSystemWatchers to keep an eye on the directories and they will send their event messages to another d...