datatable

DataTable.DefaultView.Sort doesn't seem to be working

I populate a DataTable, then sort the DefaultView of that DataTable. When I set the DataTable as the source for my report, the sort doesn't work. In case it helps, here is the code (GetData returns a valid DataTable): Dim dt As DataTable = a.GetData(Parm1, Parm2, Parm3) If rbtSortByField1.Checked Then dt.DefaultView.Sor...

Reading multiple tables from MDB file into Dataset

I have an MDB file created with Microsoft Access 2007. I would like to read the 10 tables from that file. I would like to avoid multiple trips to the database so I would like to get all the data into memory when the for loads. And I will commit any changes when the form is closed. Can I create 1 DataSet and fill it up with all 10 tab...

VB.NET problem converting DataTable to JSON

Ok so I'm trying to use the JavaScriptSerializer to work with this code. However it crashes when it reaches the last line; Dim json As New String(sr.Serialize(dt)) I get this error message; A circular reference was detected while serializing an object of type 'System.Reflection.Module'. I would really appreciate any insights...

Add new column and data to datatable that already contains data - c#

How do I add a new DataColumn to a DataTable object that already contains data? PseudoCode //call SQL helper class to get initial data DataTable dt = sql.ExecuteDataTable("sp_MyProc"); dt.Columns.Add("MyRow", type(System.Int32)); for(DataRow dr in dr.Rows) { //need to set value to MyRow column } ...

From DataTable in C# .NET to JSON

I am pretty new at C# and .NET, but I've made this code to call a stored procedure, and I then want to take the returned DataTable and convert it to JSON. SqlConnection con = new SqlConnection("connection string here"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand("getDates", con); SqlParame...

Problems with Clearing InputText in a JSF Datatable

I'm trying to reset some input text fields, inside of a data table, using a cancel button. The issue I'm having is that, if I attempt to cancel it, but there are validation errors, it does not allow me to do so because it does validation first, finds and error, and outputs the error before it can rerender itself. The obvious solution is...

Object Reference Error filling a datarow

This is the code: Dim dr() As DataRow = DataSet.Tables("TableName").Select("EVENTNAME = '" & name & "'") I get an "Object reference not set to an instance of an object." Error when this line is executed. It is looping through a list of selected items in a listbox. I think it has to do with how I have the datarow declared because I c...

Why can't I do foreach (var Item in DataTable.Rows)?

Is there a reason why I can't do the following: foreach (var Item in DataTable.Rows) { rather than having to do foreach (DataRow Item in DataTable.Rows) { I would have thought this was possible, like it is on other datatypes. For example: foreach (var Employee in Staff) { // string[] Staff etc... When I try the first foreach loo...

Need to get empty datatable in .net with database table schema.

What is the best way to create an Empty DataTable object with the schema of a sql server table? ...

YUI datatable error

Hi, I'm trying to put together an application which uses YUI's DataTable component but I get the "Data error" message. The datasource is configured to get the records from an ASP.NET web method. The records are returned to the client side successfully (I checked it with IE's debugger). My code looks like the following: YAHOO.example.Ba...

How to add gridview rows to a datatable?

I have a gridview which will contain some 'n' number of rows.... Now i want to add all rows of the gridview to a datatable which will be used for bulkcopy operation... I have found this http://www.codeproject.com/KB/aspnet/GridView_To_DataTable.aspx But i want all columns of my gridview to be added to the datarow of the datatable I ...

.Net Framework DataTable.Select(String) method when the filter expression contains ' or "

In a .Net web application I use the public DataRow[] Select(string filterExpression) method in many places. Due to a last minute change characters such as ' and " are now valid input. What options do I have, is there a way to change the filterExpression in an adequate way and still preserve the Select functionality on the datatable, can...

SharePoint ItemAdded Event Delay

Yet another question. So now my EventReceiver and its logic is working just fine. Except for one thing. Basically it queries the whole list through CAML queries, and then passes the result to a DataTable object, and later on to a DataRow object... Like all, in test environment, it works perfectly, but in production... What happens is...

Why is a row added to session datatable disappearing on refresh of page?

I have set up a class as a facade to access the session variables for my app. In this app I store an entire dataset for a particular employer as a session variable. Within one of the sub pages I have a button that adds a row to an existing table stored in that dataset. Dim curRow As Data.DataRow = mySession.tWorksiteOtherMeasures....

Why should or shouldn't I store a Dataset, Datatable, etc as a session variable in an ASP.NET page?

I am working on a web application that is consuming a Dataset returned by a web service. As the application is running I store that Dataset as a session variable to be used over and over again as the user navigates to the different pages that will edit the tables within the dataset. The idea was the user will only have to wait for t...

Safely Removing DataRow In ForEach

I dont understand why I cannot do the below - This should work?? foreach (DataRow dataRow in dataTable.Rows) { if (true) { dataRow.Delete(); } } ...

Extend Richfaces components - for example customize Datatable component for specific implementation

Hi, How to extend the functionality of Richfaces components for example Data table with custom header and sorting techniques. i have seen extended data table but did not get much information from it. Please point me to an example if at it is available. Thanks Soma ...

Are there any other way to fill a Datatable in ADO.Net without using dataadaptor.Fill method?

hi Are there any other fast way to fill a Data table in ADO.Net without using Data adaptor.Fill method? ...

How to save a datatable if it contains an object that refuses to serialize?

Hello expert coders, I'm storing GData "Event" objects from the Google API in a datable (Ok, I had to cast them as an object or they wouldn't go in), and I can access all the properties of the events perfectly, and use them to update Google, but I cannot serialize the datatable (or a parent dataset) to file because: Type 'Google.GData.C...

Is there a code-generator to create DataTable definition block from Excel Work sheet?

Hi, Basically the thing I want to achieve is to have a data-table that I want to use in my unit tests. And when I run my unit tests, I do not want to read any excel file into a data-table -or any call to Db-. So, I would like to have method that returns a data-table with the values that I can use in my test. Is there already any writ...