datatable

.NET DataTable skips rows on Load(DataReader)

I'm trying to populate a DataTable, to build a LocalReport, using the following: MySqlCommand cmd = new MySqlCommand(); cmd.Connection = new MySqlConnection(Properties.Settings.Default.dbConnectionString); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT ... LEFT JOIN ... WHERE ..."; /* query snipped */ // prepare data dat...

Compare datatables

Hi, I built an application which displays the records from database in the window and checks the the database for new records every couple of seconds. The problem is that the window blinks each time I check for new records and I want to fix it. I have tried to compare the old datatable with the new one and refresh only if they are diffe...

Querying DataColumnCollection with LINQ

I'm trying to perform a simple LINQ query on the Columns property of a DataTable: from c in myDataTable.Columns.AsQueryable() select c.ColumnName However, what I get is this: Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Select' not found. Consider explicitly specifying the t...

Table NewRow() Causes Memory Leak

Whilst investigating a memory leak I discovered that it was caused by calling NewRow() on a Table inside a loop many times. However the DataRow created was never added to the Table Rows collection and the Table Rows Count never got above zero. My question is why does this use up more memory every time NewRow is called even though the ne...

Best way to get a comma delineated string into xml format?

Using VB.net (.net 2.0) I have a string in this format: record1_field1,record1_field2,record2_field3,record2_field1,record2_field2, etc... I wonder what the best (easiest) way is to get this into an xml? I can think of 2 ways: Method 1: - use split to get the items in an array - loop through array and build an xml string using conc...

best practice for retrieving data which meet selected conditions

Hi, I have a database table named call with columns call_time, location, emergency_type and there are three types of emergency: paramedics, police and firefighters. In the windows form I created CheckBoxes 'paramedics', 'police', 'firefighters' and I want to retrieve all table columns which meet user's selection. I created a function: ...

C# - Fill a combo box with a DataTable

I'm used to work with Java where large amounts of examples are available. For various reasons I had to switch to C# and trying to do the following in SharpDevelop: // Form has a menu containing a combobox added via SharpDevelop's GUI // --- Variables languages = new string[2]; languages[0] = "English"; languages[1] = "German"; DataSet ...

How to bind a label inside a gridview to another table?

I have a very standard Gridview, with Edit and Delete buttons auto-generated. It is bound to a tableadapter which is linked to my "RelationshipTypes" table. dbo.RelationshipTypes: ID, Name, OriginConfigTypeID, DestinationConfigTypeID I wish to use a label that will pull the name from the ConfigTypes table, using the "OriginConfigTypeID...

How to properly set a datatable to an gridview in code with an ObjectDataSource?

Hello, I have an ObjectDataSource with an ID of ObjectDataSource1 on a webpage. I also have a gridview in which I am binding the ObjectDataSource.ID to the GridView.DataSourceID. The problem I get is when text is changed in a textbox, the code calls BrokerageTransactions.GetAllWithDt which returns a DataTable. I want to set this data...

Home-grown ORM vs. DataTables?

This is a simplification of the issue (there are lots of ways of doing things), but among applications that need to talk to a database I have usually seen one of two patterns: Object-Relational Mapping (ORM), where (usually) each table in the database has a corresponding "row wrapper" class with public properties that match the columns...

Custom datatable with metadata used for binding to a Gridview?

I'm binding a datatable to a gridview control, and when I format each column I need to format the data based on whether that column has a particular custom attribute. In this case, a column can represent: a text box (in which case I just display the text from the textbox in the gridview), a checkbox (in which case I display "Checked" ...

Merge 2 DataTables and store in a new one

If I have 2 DataTables (dtOne and dtTwo) and I want to merge them and put them in another DataTable (dtAll). How can I do this in C#? I tried the Merge statement on the datatable, but this returns void. Does Merge preserve the data? For example, if I do: dtOne.Merge(dtTwo); Does dtOne change or does dtTwo change and if either one...

SharePoint list.items.GetDataTable column names not match field names

I am binding an SPGridView to a SPList. As code samples suggest, I am using the following code to create a dataview based on the list. dim data as DataView = myList.Items.GetDataTable.DefaultView grid.DataSource = data etc... What I am finding is that the column names in the resulting dataview do not always match the source fields de...

Dynamically Generated Datatable for Google's Annotated Time Line

I want to use Google's Annotated Time Line Visualization. It is very easy to make this work by manually adding the lines for column & row data. This is all done through attributes of google.visualization.DataTable(). I would like to update this data table dynamically, but I do not know how. The data is on a server running MS SQL Server ...

How to display the row index in a JSF datatable

In a JSF dataTable I want to display the row index next to the rows... like: Column A Column B 1 xxx 2 yyy I thought that I could use an implicit el variable like #{rowIndex} but this is not working. A solution I found is to create a binding for the data table and use the binding like: <h:dataTable var="item" ...

Handling updates to a Cached DataTable when the users session holds DataViews based on that DataTable

My website runs on a single server. I am caching a DataTable. Each session has a refernce to it's own DataView referring to that DataTable. What I am worried about is when I need to make changes to the underlying datatable will they propagate to each of the sessions references to it. Or is there a better way to handle this situation. ...

Iterate over HashMap.values() in JSF+Facelets

I'm using JSF/Facelets, and I'm trying to iterate over some Document objects (custom object) that I'm keeping in a HashMap. When the page is loaded, I'm getting the error "Property 'name' not found on type java.util.HashMap$Values". Here's what's in my backing bean: private Map<String, Document> documents = new HashMap<String, Documen...

How do I use the find method of a datatable with a compound key?

I am working on a windows form application. How do i use the find method of a datatable to find a row if the datatable has a compound key? Table Structure Col A, Col B, Col C Col A and Col B make up the compound key. I want to find the row where the value in Col A is 6 and Col B is 5 ...

how to convert Gridview to Datatable

Hi all I am using GridView in my application for populating datas. Is there any easy way to copy a gridview to datatable ? Actually, in my GridView one of the control is textbox. So I can edit that control at any time... What I need is on the button click whatever changes I made in GridView has to copy in one datatable... I did this...

Do I have to call dispose after each use though datatable is stored in cache?

Simple case: i put a DataTable in Cache DataTable table = SomeClass.GetTable(); Cache["test"] = table; then in later calls i use DataTable table = (DataTable)Cache["test"]; now the question is: should i call table.dispose() on each call, though its stored in the Cache? Means the object is always the same? Or will Cache create a copy...