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 ...
I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is not DBNull.
I already check for DBNull but I don't know how to make sure the column...
I am trying to convert all DateTime values in a DataTable to strings. Here is the method I use:
private static void ConvertDateTimesToStrings(DataTable dataTable)
{
if (dataTable == null)
{
return;
}
for (int rowIndex = 0; rowIndex < dataTable.Rows.Count; rowIndex++ )
{
for (int i = 0; i < dataTable....
What's the best performing way to convert a DataRowCollection instance to a DataRow[]?
...
Howdy,
I have a DataSet with a DataTable that fills a single row through a TableAdapter.
The TableAdapter is correctly filling a DataRow in the DataTable.
I am able to pull data from the DataRow with code like this:
dataFileID = (int)this.dataFileDataRow["DataFileID"];
dataFileName = (string)this.dataFileDataRow["DataFileName"];...
When we use datatable.newrow command, a new empty row added to bottom of rows. However I want newrow to added to top of datatable. How can I make it?
...
I am currently building a method that takes an object that is of type DataRow from a typed DataSet, and then returning a string in JSON format of the fields in the DataRow (for use in a Web Service).
By using System.Reflection, I am doing something like this :
public string getJson(DataRow r)
{
Type controlType = r.GetType...
When retrieving values from a DataRow is it better to use the column name or column index?
The column name is more readable and easier to maintain:
int price = (int)dr["Price"];
While column index is just faster (I think):
int price = (int)dr[3];
Would using column names break if you decide to obfuscate the database?
...
[UPDATE: MS SQL Server 2005]
Hi is it possible to select a bunch of values, and then assign a column in the select statement as the primary key?
SELECT ID FROM HQ AS PRIMARYKEY -- this is wrong
SELECT Names FROM Stores
SELECT PRODUCTNAME FROM PRODUCTS
I ask this because I want to take advantage of the DataRow find method in .net, tha...
Say the object is as follows:
string Name
Dictionary<string,bool> Tags
Where tags is dynamic, but there is a list of tags stored in a Collection in the core data object.
I want to be able to display this in a datagrid like so:
Name tag1 tag2 tag3
Bob true true
John true true
I left out false, but that could be in ther...
I'm working on a Generic Reporting Tool, where each report is represented by a row in Reports table in database.
Report row structure:
ReportID ReportFileName
RepParam1Name RepParam1Type RepParam1Value
RepParam2Name RepParam2Type RepParam2Value ... RepParam10
So, I need to retrieve report parameters (N...
I'm trying to compare two DataRows in a loop. However, the following if statement doesn't return true:
if (dt1.Rows[0]["Name"] == dt2.Rows[b]["Name"]) {
// This never executes
}
However, if I add .ToString() to the end of each DataRow, the if statement returns true:
if (dt1.Rows[0]["Name"].ToString() == dt2.Rows[b]["Name"].ToStri...
I am delevelopring my first MVC application and I am using a classic ADO.NET dataset as a model. The guide I am following is the NerdDinner ASP.NET MVC Tutorial and it mentions a GetRuleViolations() method for a Linq To SQL model. I would like to have a similar method to check that a datarow is valid after editing. How could I do such a ...
So I am building some XML using a XmlWriter and a DataSet but when it comes time to loop through each DataRow in the DataSet I can't figure out how do reference like "userid" and such that come back from the stored procedure. In page code I see them doing it as Eval("userid") or whatever which I am using the same stored procedure, but I ...
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 is null:
if (resultSet.Rows[0].ItemArray[resultSet.Columns.IndexOf("fk_id")] == null)
{...
One of the method signatures for the DataRow Add Method is:
DataRow.Add(params object[] values)
When using the above, if I am passing in some strings for example, do I have to do it like the following:
DataRow.Add(new object[]{"a","b","c"});
or can I just do it like the following:
DataRow.Add("a","b","c");
Would both ways work?
...
Hello everyone
I have to bind datarows to my controls. So far so good. The problem now is, that my datarow contains only strings in the column I have to bind, but of course the property "checked" of a Checkbox takes only boolean arguments.
Is there a way to use DataBinding here? Maybe with some kind of converter in between?
Thanks
...
I'm looking for a method or an event that would get fired when a row in a datatable is accessed.
I have a datatable with several thousand rows, and an image in at least one of the columns. I want to dynamically load and unload the image from the row when it gets accessed.
I haven't seen any documentation that suggests that it's there, ...
hello,
i have System.Data.DataRows with several fields, most of them just plain types like int, single, string.
what is the best way to make them editable using a propertygrid?
it should work automatically no matter what kind of fields the datarow has, but it should not display all of them. i want to provide a list of properties that s...