I'm using a third party library which returns a data reader. I would like a simple way and as generic as possible to convert it into a List of objects.
For example, say I have a class 'Employee' with 2 properties EmployeeId and Name, I would like the data reader (which contains a list of employees) to be converted into List< Employee>.
I...
Hi,
I am importing data to Excel sheets from a database. For this, I am using datareader. The excel sheet template has some macros and few formulae calculated and its not the normal excel worksheet. so I have to write the data into the excel sheet only if the particular cell is allowed to write. If not, the data shouldn't be imported.
...
I have a query which returns data for a number of dataseries in one lump.
I would like to split this data up into the data series id, by the dataseries id. The query cannot be changed.
Its not safe to assume that the data is ordered by the series id, so what would be the best way to do this? LINQ?
...
Hi!
Can I avoid the open DataReader exception ("There is already an open DataReader associated with this Command which must be closed first.") when using constructs like this one?
public void FirstMethod()
{
using (var command = connection.CreateCommand())
{
command.CommandText = "...";
using (var reader = comma...
Say I have this class:
class myclass
{
public int Field1{ get; set; }
public int? Field2 { get; set; } //Note Field2 is nullable
}
I'm trying to populate a generic list with data coming from a database. As GetSqlInt32 implements INullable I would have thought that the below code would work. It doesn't. It generates an error ...
I'm having the data in datareader which i want to be converted in list.
What is possible simple solutions for this?
For e.g.In CustomerEntity class, I'm having customerId & CustomerName properties.If my datareader returns these two column data. then How can i convert it into List <>.
ohh amazing not able to write customerEntity in <>
...
I'm having let's say thousands of Customer records and I have to show them on a webform. Also, I have one CustomerEntity which has 10 properties. So when I fetch data in using a DataReader and convert it into List<CustomerEntity> I am required to loop through the data two times.
So is the use of generics suggestable in such a scenario? ...
I'd like to know what the advantage of using a DataRelation in .NET is, as opposed to crafting the relationship in the data layer itself? Or is this largely a decision by the developer about which tier to place their logic in?
...
When should I use DataSet instead of DataReader?
When I must use DataSet instead of DataReader?
When should I use data in a disconnected fashion?
When I must use data in a disconnected fashion?
N.B.
I am not asking which is better. I need to know the appropriate scenarios of the use of DataSet. I am programming in .net for couple o...
We are having some issues with our data layer when large datasets are returned from a SQL server query via a DataReader. As we use the DataReader to populate business objects and serialize them back to the client, the fetch can take several minutes (we are showing progress to the user :-)), but we've found that there's some pretty hard-c...
Hi,
As my experience with .Net really began as working on existing in-house applications for a company, I feel I've picked up so many bad coding practices without realising it. One that i am desperately trying to move on from is that DataSets are used for everything. (I do get that strongly typed datasets have there place and they certai...
Hi,
I have successfully switched my project from odbc.datareader to mysql.datareader. The problem is that with the first one /odbc datareader), the AffectedRows property retrieves the number of rows correctly even when it was pure query. But it doesn work with mysql.datareader, its -1 then.
So I cannot see the way how to retrieve the num...
I have a BufferedReader looping through a file. When I hit a specific case, I would like to continue looping using a different instance of the reader but starting at this point.
Any ideas for a recommended solution? Create a separate reader, use the mark function, etc.?
...
OK. I am using the C# programming language to access a simple database (on Microsoft SQL Server)
Currently, I am using the DataReader object to access the database.
So here is my question: is it possible to do a binary search (in C#) for a particular piece of data so that i can make the search faster?
Currently, I'm using a simple whil...
MySqlDataReader rdr = cmd.ExecuteReader();
i have a some information in my mysqldatareader.
how can i show it on our web-pages
I don't know how i can use it .it means mysqldatareader.
also welcome for simple source code.
...
I've never tried this - so I don't know if I'd run into memory issues.
But can a SqlDataReader read a trillion records? It's all streamed correct? I'm a little green to what the SQL/TDS protocol is doing under the covers.
UPDATE
Translate Trillion to mean very large number. I probably should have said something like 1 billion or 100 mi...
With ms access as the database storage software.
And if you know of other ways on how to read data base on a certain criteria and displaying the results that meets the criteria.
...
Similar to this question, but the answers never really got around to what I want to know. Is there any standards around getting values from a DataReader? I.e., is this
dataReader.GetString(dataReader.GetOrdinal("ColumnName"));
considered better/worse/the same as this?
(string) dataReader["ColumnName"];
...
I am reading from a SQL datareader in C# and passing the values from the columns to a dropdownlist. There are two columns being read. Using IsDbNull, I am able to handle the null values. However, as I have the code written right now, if dr.GetString(0) is null, no values are passed along at all, while as long as only dr.GetString(1) (or ...
I have a SELECT query that yields multiple results and do not have any ORDER BY clause.
If I execute this query multiple times and then iterate through results using DataReader.NextResult(), would I be guaranteed to get the results in the same order?
For e.g. if I execute the following query that return 199 rows:
SELECT * FROM product...