idatareader

IDataReader and "HasColumn", Best approach?

I've seen two common approaches for checking if a column exists in an IDataReader: public bool HasColumn(IDataReader reader, string columnName) { try { reader.getOrdinal(columnName) return true; } catch { return false; } } Or: public bool HasColumn(IDataReader reader, string columnName) { reader.G...

How do I convert a DataTable to an IDatareader?

We all know that DataReaders are quicker than DataTables since the a DataReader is used in the construction of a DataTable. Therefore given that I already have a DataTable.... Why would I want to convert it to a DataReader? Well I am creating an internal interface called IDataProvider. This interface is intended to be implemented both ...

Does IDataReader.GetName(i) work with empty data readers?

I want in the case of an empty data reader to output the field names with empty values.. ie Product: - Price: - So, are IDataReader.GetName(i) and IDataReader.FieldCount safe to use when they have no results? ...

Does a IDataReader get automatically get closed when set as a datasource?

When you assign an active IDataReader object to either a Repeater, GridView, etc., does it automatically get closed upon completion of the DataBind method call or do we still need to explicitly close it ourselves? this.sampleRepeater.DataSource = ExampleDAL.GetIDataReader(); this.sampleRepeater.DataBind(); ...

MySqlConversionException when accessing DateTime field from DataReader

Hello again, I have a C# application over MySql, using MySQL Connector; I'm trying to make a DataReader request, the query executes fine, however, when trying to access a DateTime field, i'm getting MySqlConversionException {"Unable to convert MySQL date/time value to System.DateTime"} this is the prototype if (dr != null && !dr.Read...

idatareader problem....

why My idatareader make error .....? byteSize = _reader.GetBytes(_reader.GetOrdinal(sFieldName), 0, null, 0, 0); I want to retrive image from database here sFieldName is database column Name......it show me Specified cast is not valid. message ......what i do?work on c# window vs05.... sFieldName is a string ....it's the column name...

i datareader can not read image

i can not read image from database by idatareader can any one help me to read it? ...

phxsoftware System.Data.SQLite DbDataReader misbehaving

The following post relates to the System.Data.SQLite data provider by phxsoftware (http://sqlite.phxsoftware.com) I have a question (and possibly a problem) with DbDataReader’s Read method and/or Visual Studio 2008. In many examples I see things like the following (and I know this code doesn't make a lot of sense ... but it serves a pu...

Best practices for getting around DB differences with an IDataReader

I have a simple value object which I populate with data from an IDataReader (could be the result of a query to either an Oracle or MS SQL database). The factory method for this object looks something like the following: internal static SomeClass CreateFromDataReader(IDataReader data) { string message = data.GetString(0); short i...

Disposing SqlConnection from a base DAL class when calling ExecuteReader

I've been assigned on a project where the DAL consists of a base class with functions to return IDataReader, an Object (int, string and the like), or a DataSet. An ExecuteNonQuery function also exists. This DAL only accesses USPs (SQL Server), and is using MS's SqlHelper to execute the queries. Here's two sample functions from the base: ...

Improving DAL perfomance.

The way i currently populate business objects is using something similar to the snipet below. using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.CDRDatabase)) { using (SqlCommand comm = new SqlCommand(SELECT, conn)) { conn.Open(); using (SqlDataReader r = comm.ExecuteReader(CommandBehavior...

Checking to see if a column exists in a data reader.

Is there a way to see if a field exists in an IDataReader-based object w/o just checking for an IndexOutOfRangeException? In essence, I have a method that takes an IDataReader-based object and creates a strongly-typed list of the records. In 1 instance, one data reader has a field that others do not. I don't really want to rewrite all...

CBO.FillCollection throwing "No parameterless constructor defined for this object." error...

I'm trying to fill a collection from an IDataReader that was returned by another method... for some reason it keeps throwing a "No parameterless constructor defined for this object." error for this line: List<string> names = CBO.FillCollection<string>(DataProvider.Instance().ExecuteReader("getNames", new SqlParameter("UserId", 1))); I...

Advantages of using SQLDataReader over a reader that implements IDatareader?

What are the advantages of using a SQLDataReader as opposed to a reader that just implements IDatareader if I'm using SQL Server >= 2005? Does the SQLDatareader simply have more functionality to choose from, or are there performance improvements using the SQLDatareader? Any articles that discuss this would be appreciated. Thanks! Ch...

Null safe way to get values from an IDataReader

Hi all, (LocalVariable)ABC.string(Name)= (Idatareader)datareader.GetString(0); this name value is coming from database.. what happening here is if this name value is null while reading it's throwing an exception? I am manually doing some if condition here. I don't want to write a manual condition to check all my variables.. I am doi...

using IDataReader to call store procedure with parameters

I use IDataReader to call stored procedures without parameters. I am not finding examples of how to do this when parameters are present. Does IDataReader handle parameters of stored procedure? Please provide an example. ...

Can I configure AutoMapper to read from custom column names when mapping from IDataReader?

Psuedo code for mapping configuration (as below) is not possible since the lambda only lets us access Type IDataReader, wheras when actually mapping, AutoMapper will reach into each "cell" of each IDataRecord while IDataReader.Read() == true: var mappingConfig = Mapper.CreateMap<IDataReader, IEnumerable<MyDTO>>(); mappingConfig.ForMembe...