I want to create a simple class that is similiar to a datatable, but without the overhead.
So loading the object with a sqldatareader, and then return this custom datatable-like object that will give me access to the rows and columns like:
myObject[rowID]["columnname"]
How would you go about creating such an object?
I don't want any...
With the help of you guys, I have created an object that is similiar to the recordset in classic asp.
public class RecordSet: List<Dictionary<string, object>>
{
}
So I can access the data like:
RecordSet rs = new RecordSet();
rs[rowID]["columnName"];
How can I get access like this also, i.e. ordinal referece:
rs[rowId][2];
Ple...
Hello everyone,
My question is how to assign the DataType value for columns of special SQL Types like, uniqueidentifier/nvarchar/datetime/varbinary(max) -- I did not find a mapping between .Net data type and such 4 types of SQL column data type?
Here is a sample, which shows we need to assign the DataType (this sample maps .Net type to...
I am using web forms, C#, Asp.net.
As we all know, in this model UI and business logic are often mixed in. How do I separate these effectively?
The example I would like to use is:
I have a GridView and a DataTable (GridView binds to the DataTable and DataTable is fed from the stored procedure).
I would like the GridView (UI) and DataT...
Is there a predefined or "easy" method of writing a datatable to a text file or TextBox Control (With monospace font) such as DataTable.Print():
Column1| Column2|
--------|--------|
v1| v2|
v3| v4|
v5| v6|
Edit
Here's an initial version (vb.net) - in case anyone is interested or wants to build their...
So what does this exactly means?
Some advised that to circumvent around this error, only bind a gridview to a dataset when the rows count of the datatable is greater than zero.
but how about if for example your search yielded no record returned, so your datatable would have no rows, but still, you can still bind to the dataset?
Aside ...
I am trying to convert a generic collection (List) to a DataTable. I found the following code to help me do this:
// Sorry about indentation
public class CollectionHelper
{
private CollectionHelper()
{
}
// this is the method I have been using
public static DataTable ConvertTo<T>(IList<T> list)
{
DataTable table = CreateTable<T>();...
I'm writing an internal web application that is used to look up credit checks. I'm using ASP.NET for this website.
I have a SQL Query that I have to query the credit check database and it returns a datatable of results. After the person clicks search, I run the query and bind the returned datatable to the Gridview every time the user ...
A project I am working on requires values from a C# application to update 6 values in an Excel sheet. This excel sheet then populates a named range of items and prices, driven by a number of VLOOKUP formulas and worksheets within the same Excel File.
The two columns in the range are named 'Item' & 'Price'.
'Item' is a column of items ...
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)
{...
I have a table with many values inside of it that might have single quotes around them. I need to create a duplicate table without those single quotes. I can't modify the original table as I need to use it, 'as-is' later.
I've done this with a table.Clone and using a foreach to loop through the rows and columns removing single quotes ...
I have a Windows form app. I get data based on a row position in a DataTable. I have a TotalCount variable and a CurrentPos variable. The button next should get the next row and the button previous should get the previous. These buttons should be enabled/disabled when there is data available.
My brain is much can you provide the logic
...
I have two datatables defined like this;
Dim db1, db2 As New DataTable
db1 and db2 hold results from different queries but the columns in both are exactly the same. I would like to create another datatable which consists of records that are in both db1 and db2. i.e I want the intersection of the two datatables. Is there an easy way to ...
I have custom some controls residing in SharepPoint webparts. I use a GridView control to take advantage of the built-in paging and column sort. The GridView gets databound from a method that iterates through an SPlist (with a foreach loop) to build a DataTable. This looping through the list is required to apply logic to process the l...
EDIT: Note. I should have mentioned I'm not interested in using the .Select, DataRowView, RowFind, etc. Thank you for those suggestions but the code as it stands, I was hoping to optimize.
I wrote a function to search a datatable for terms in an array. I then return the datatable as a dataset so it can be bound to a DataGridView. Do...
If you have a DataTable that has a column of some Enum type.
And you bind a DataGridView to this DataTable (myDgv.DataSource = myDataTable)..
How can you make the DataGridView show a combobox (or is it drop-down-list? The one where the only thing you can do is select) in each cell of for this column? The combobox should have the curren...
I am wanting to know if there is any way to have multiple footer rows in a h:dataTable (or t:datatable) I want to do somthing like this (which does not compile)
<h:dataTable ... var="row">
<h:column>
<f:facet name="header">
Header
</f:facet>
<h:outputText value="#{row.value}"/>
<f:facet name="footer">
FirstF...
I found the following example on http://www.erictobia.com/2009/02/21/LoadADataTableWithLINQ.aspx
Unfortunately, I need it in VB and it's using some constructs that neither I nor the automated code converters reciognize. Anyone out there know how this should be written in VB.Net? (the problem spot is the "select new {...")
PeopleData...
I have a very strange requirement using DataTable. I have a datatable with some columns. Nwo whenever there is any change in any of the DataRow in the datatable; then the state of DataRow is set to modified. That is OK. But for one exceptional column I don't want this behavior. I want that any change in any row for this particular column...
I have a datatable object, which is populated from a webservice.
Apparently, the web service just throws everything (data) back to me. The data which gets in my datatable looks like this:
Dept Code Value
Science ABC 5
Science ABC 6
Science DEF 7
Math ABC 3
Math DEF 9
English ABC 2
Engl...