datacolumn

Using old-school ado but can anyone improve this using L2S or dynamic sql

I am rolling through all the cols on a particular row for processing. I am looking in general to replace using ado.net with L2S or some dynamic sql that can positionally read the columns on a particular row for processing. This is my test code. I apologize for inefficiencies like sending the DataTable down to find the col name. It is a...

How to make addition of two columns data for another column where those two columns are type of string ?

I have datatable and there two column which is type of string and I want to make addition of that two columns data for another column how can I do that ? My column name contains special character and I have used "[" "]" to escaping special character and my columns are type of decimal I am doing TableExtractedFromFile.Columns[TOT BRO...

DataTable.Select Behaves Strangely Using ISNULL Operator on NULL DateTime Column

I have a DataTable with a DateTime column, "DateCol", that can be DBNull. The DataTable has one row in it with a NULL value in this column. I am trying to query rows that have either DBNull value in this column or a date that is greater than today's date. Today's date is 5/11/2010. I built a query to select the rows I want, but it di...

A null value should be considered as 0 when addition of it is done with decimal value.

There are three column in the datatable A,B and C. Now each column is type of decimal. Now I am doing like dt.Columns["A"].Expression="B+C"; to make addition of Column B's record and column C's record. Now if there is any value of B or C is null then addition of B and C will be null like B's value is 3 and C's value is null for first row...

Testing equality of DataColumn values in C#

Hi all I've written some code to test equality between column values in DataTables when the column type isn't known. Testing directly like this: row["Foo"] == row["Bar"] always results in false, presumably because object's implementation of Equals uses ReferenceEquals. So I've resorted to: row["Foo"].ToString() == row["Bar"].ToStr...

How to save an expression datacolumn to the database?

I have a datagridview on a form with multiple columns. Three of the columns are expression columns. One column is subtracted from the second and the result is displayed in the third. Everything works great but when I hit the save button and save to the database, all the columns are saved to the database except the three columns used in t...

DataReader, DataColumn - Can These Show Me Columns In Schema Such as SomeSchema.SomeColumn?

I have a database table where columns are in multiple schemas. Example: SomeTable SomeSchema.Column1 SomeSchema.Column2 AnotherSchema.ColumnA AnotherSchema.ColumnB I have code using a DataTable.Rows[r][c].ToString() syntax and it looks like only the Column1 or ColumnA part is being returned. I need to get the full name SomeSchema.Co...

In WPF, how can I bind a datagrid column to a specific column of a datatable?

I have a Datatable with many columns, and a datagrid in which I need to display only a few of those columns. I need a codesample of how to do it. I found a whole bunch of examples telling me to turn AutoGenerateColumns to true and set the table as DataContext to display all the columns in my DataTable. And I guess I could then put in a p...

Change the value of every cell in a DataTable column

I have a System.Data.DataTable which I'm binding to a GridView. If the user doesn't have a certain security role, I want to replace the data in certain columns with an "X". Can I do this without looping through all of the rows? ...

Programatically set the width of a DataColumn for use with a DataGrid

I assign a column programmatically to a DataTable like this: myDataTable.Columns.Add(myDataColumn); Is there a way to programmatically set the width / size of the column? I'm using WPF with C# in vs2010. ...