datatable

Datatable Compute Function for multiple colmuns

I want to count the number of non-null values per column in a Datatable. I could loop through the columns and use the compute function on each column, but I was wondering if there is a more efficient way to do this. ...

DataTable.DefaultView- Explanation Needed C#

Here's the code that's disturbibg me a bit.. DataTable dt=GetDataTable(); for(int i=0<dt.Rows.Count;i++) { string Name=dt.DefaultView[i].Row["FirstName"].ToString() } I need explanation of this, what actually dt.DefaultView[i] means here ? ...

Standalone DataTable in .Net

Can I use the DataTable class like this: DataTable client = new DataTable("client"); int primay_key = 1; DataRow row = null; row = client.findBy(primary_key); After findBy, will the row object contains a row from the database? I cannot find a example like that on the internet, looks like the .net built in DataTable class is not wh...

How do I bind my controls in a WPF DataGridTemplateColumn to a DataTable?

I have a DataGrid bound to a DataTable that I want to make custom columns for using a DataGridTemplateColumn, but I'm not sure how to reference the value in the cells of the DataTable. Every example I see online either binds the DataTable and doesn't change the templates, or uses a custom object and references the properties of the bound...

ADO.net without writing SQL (esp. WHERE)

I have this idea that using SQL VIEWS to abstract simple database computations (such as a count on a relation) is sufficient, and you don't need procedures (== procedural code) A simple sql view + a where clause >> a stored procedure with parameters sometimes While making this point I imagined a way of retrieving table/view data withou...

How can I refresh a YUI dataTable with a button?

I'm testing the script: http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson.html I would like to add a button to refresh(reset) the data. I would reset all modified data and reload first data. I add this code, so after select (refresh), I have no data: YAHOO.util.Event.onContentReady("splitbuttonsfromjavascript", function...

Loop through the rows of a particular DataTable

IDE : VS 2008, Platform : .NET 3.5, Hi, Here is my DataTable columns : ID Note Detail I want to write sth like this : //below code block is not the right syntax For each q in dtDataTable.Column("Detail) strDetail = Row of Column Detail Next Can anyone give me a suggestion and show me a code sample please ? Thanks. ...

How can I update a row in a DataTable in VB.NET?

I have the following code: Dim i As Integer = dtResult.Rows.Count For i = 0 To dtResult.Rows.Count Step 1 strVerse = blHelper.Highlight(dtResult.Rows(i).ToString, s) ' syntax error here dtResult.Rows(i) = strVerse Next I want to add a strVerse to the current row. What am I doing wrong? ...

Error - Lable shows System.Data.DataRow

Hi, I've been trying to highlight a search result in DataTable. First, I loop through rows of DataTable and call a function to look for a matched keyword to highlight those words, then update DataTable row with a new string with highlighted keywords. I bind the DataTable dtResult to the DataList. It worked fine until I added this code ...

Predicate on DataView Constructor?

I know this may sound crazy, but I swear that on two separate ocassions via intellisense I've seen an overload for the DataView constructor that took in a DataTable and either Predicate or Func, I don't remember what T was, either DataRow or DataRowView. But now I can't find it. It also took in another parameter, I want to say it was a C...

How do I smoothly update a GridView by updating the bound DataTable in C#?

Hi, I have a GridView who's DataSource is set to a DataTable. The DataTable is updated by some backend logic every few seconds, at which point a delegate is called to refresh GridView. Currently I am simply resetting the DataSource, but that causes a problem - it interrupts any ongoing edits in the grid view and makes the selection 'ju...

How to specify table name in Fluent NHibernate ClassMap class?

Hi I am newbie to NHibernate and trying to use Fluent for mapping. My entity class name is different from the database table name it has to be mapped to. I am using mapping class derived from ClassMap<>, but I can't specify the table name: the property TableName from ClassMap is read-only. Thanks for your help. ...

Save snapshot data to XML

I have 5 tables belonging to 2 different datasets, I use them to populate some grids in a page. I want to implement some snapshot functionality and I need to save the data in the tables in an XML in the database. I was thinking of simply serializing the tables to XML using the .Net XmlSerializer (deserializing also), but there is a lot o...

Fastest way to join mysql 4.0 data from multiple tables?

Hi, I have 3 mysql 4.0 tables: all have fields ID(int), type(int) and another field, value which is either varchar(255), tinyint or int. I need to write them all out and I end up getting three DataTables, looping over them, and creating rows into a temporary table (in .NET 1.1). Do you see any faster/cleaner way than this to join or ju...

DataTable Copying

Hi I have a datatable with 5 columns and I would like to copy only two of those columns to another datatable. What is the best way to do this? DataTable 1: col1 col2 col3 col4 col5 1 2 3 4 5 6 7 8 9 10 DataTable 2: col1 col2 1 2 6 7 Thanks ...

how do I display time in a windows forms dataGridView bound to a datatable

hello, I fill a datatable from using the fill method from a SqlDataAdapter. I then bind it to a DataGridView using the DataSource property dataGridView1.DataSource = mydataTable; I would like the DateTime columms to also show the seconds. what do I need to change to default to shoing the seconds. Thanks ...

LINQ - join 2 datatables - wildcard

I am using LINQ to join 2 datatables. I am trying to get back only 1 field from dtTable2 and all the fields from dtTable1. When this code executes, I have two columns. The first column contains the value from dtTable2.field2 and the second column has the value "System.Data.DataRow". I know that if I explicitly specify the columns in ...

optimize updates to DataTable bound to DataGridView

I have a Form in my application that displays some data. When I first show the Form, I load some data into a DataTable then bind the DataTable to a DataGridView. I also start an asynchronous method that executes some slower database queries. When these slow queries complete, I need to update a few hundred rows in the DataTable, filling i...

DataTable.Select Expression using IN and Like.

Greetings, I have two questions regarding a DataTable.Select(): 1) How to escape potential apostrophes or any other characters that would cause an issue. I'm not worried about SQL Injection. 2) How to use IN with Like, and include results that have a null. 1) Unfortunately, I can't seem to find any advice for the first option since...

DataTable and Viewstate

looks like DataTable.Rows property is not saved in ViewState but the Columns property is, because I can't explain why columns persist between postbacks and the data doesn't. Any ideas? ...