Questions tagged [datarow]

DataRow is an ADO.Net class that represents a row of a data in a DataTable.

755 questions
15
votes
2 answers

DataTable's Row's First Column to String Array

I have a DataTable. I want to get every rows first column value and append to a string array. I do not want to use foreach looping for every row and adding to string array. I tried this, but stuck at some point DataRow[] dr = new…
Yagiz Ozturk
  • 5,408
  • 7
  • 29
  • 44
15
votes
8 answers

Check if row exists in DataTable?

I have a datatable and a row. I want to import the row to the datatable only if it does not exist in the datatable. How can i do that?
Curious
  • 474
  • 1
  • 8
  • 25
15
votes
11 answers

How to Convert DataRow to an Object

I created a DataRow on my project: DataRow datarow; I want to convert this DataRow to any Type of Object. How could I do it?
folk
  • 687
  • 3
  • 8
  • 16
14
votes
1 answer

Powershell - Parse System.Data.DataRow to String

I need your inputs on how to convert the output from a SQL query into a string in powershell. I am currently doing the following function ExecuteFromScriptRowset($connectionParams, $file) { return (invoke-sqlcmd @connectionParams …
infinity
  • 1,900
  • 4
  • 29
  • 48
13
votes
2 answers

copy a single row from one datatable to other

I have two datatables one has few rows other is empty. I am running a loop over first one to copy some of the rows to another table. I am getting error 'The row already belongs to another table'. Is there any way to copy DataRows one by one to other…
MaxRecursion
  • 4,773
  • 12
  • 42
  • 76
12
votes
6 answers

Convert datarow to int

I have a datarow, but how can i convert it to an int ? I tried this, but it doesn't work. dsMovie = (DataSet)wsMovie.getKlantId(); tabel = dsMovie.Tables["tbl_klanten"]; eersteRij =…
Steaphann
  • 121
  • 1
  • 1
  • 6
12
votes
4 answers

DataRow is zeroising the decimal part of a decimal when updating Datatable

I am trying to update a DataTable that is retrieved from a DB before binding it to a Gridview. However, when I update decimal fields the part after the decimal point is zeroised. What am I missing? if…
Ben Drury
  • 1,356
  • 2
  • 16
  • 34
12
votes
2 answers

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…
Andrew
  • 12,991
  • 15
  • 55
  • 85
12
votes
5 answers

"Object cannot be cast from DBNull to other types"

When my website gets to the following bit of code, it falls down with an exception as follows: System.InvalidCastException: Object cannot be cast from DBNull to other types. For the interests of brevity, I'm showing only the relevant code (it's a…
TZHX
  • 5,291
  • 15
  • 47
  • 56
11
votes
5 answers

DataRow.Field(string Column) throws invalid cast exception

Good day, IDE Visual Studio 2010 .NET 3.5 Platform WinForms The SO question " difference between getting value from DataRow " refers. I have a database table with a column [ID] INT IDENTITY(1, 1) NOT NULL PRIMARY KEY. When querying this table and…
that0th3rGuy
  • 1,356
  • 1
  • 15
  • 19
11
votes
3 answers

C# DataTable ItemArray returns '{}' - how can I test for null value?

I have a DataTable resultSet; - I'm trying to check fields for null, but get an '{}' (empty-set ?) object back. Searches involving "{}" aren't yielding any appropriate solutions. This is the code that isn't working as expected when the "fk_id" field…
Nick Josevski
  • 4,156
  • 3
  • 43
  • 63
11
votes
1 answer

How do you read a byte array from a DataRow in C#?

I have a DataSet with a DataTable that correctly fills a single DataRow through a TableAdapter. I am able to pull data from the DataRow with code like this: dataFileID = (int)this.dataFileDataRow["DataFileID"]; dataFileName =…
Keith Sirmons
  • 8,271
  • 15
  • 52
  • 75
11
votes
1 answer

Add data row to datatable at predefined index

I have a datatable with one column: this.callsTable.Columns.Add("Call", typeof(String)); I then want to add a row to that datatable, but want to give a specific index, the commented number is the desired index: this.callsTable.Rows.Add("Legs");…
RSM
  • 14,540
  • 34
  • 97
  • 144
11
votes
3 answers

Error in datarow,Collection was modified; enumeration operation might not execute

I have for-each loop in which the data row is updated so the exception ,Collection was modified; enumeration operation might not execute is generated. any way to fix it? i have seen To-List function but it is not working with data row , here is my…
mani
  • 133
  • 1
  • 1
  • 7
10
votes
3 answers

DataTable - foreach Row, EXCEPT FIRST ONE

I am using a DataTable for some calculations in my app. I need to do the iterate trough all the rows except the first one. Is it possible? Something like: DataTable dt; foreach (DataRow r in dt.Rows /*EXCEPT THE FIRST ONE*/) { //do…
user1080533
  • 865
  • 2
  • 21
  • 35
1 2
3
50 51