.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links


Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

hi there ,

I have this part of code and I  using entllib 5 : 



 Database DB = DatabaseFactory.CreateDatabase("Cs");

        using (IDataReader Reader = DB.ExecuteReader("select"))
            GridView_Video_Download.DataSource = Reader;





and I get this error : Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

is there anybody help me ?


View Complete Post

More Related Resource Links

Help: SqlDataReader dr = command.ExecuteReader();

Hi,   I downloaded the code of  this great article  "GridView with Thumbnail Images - Part 1" http://www.codedigest.com/Articles/ArticleFiles/ZIPS/102.zip   I have no problem uploading the images. but I have problem to load it intoGridView. The reason is : Incorrect syntax near '='. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '='.Source Error: Line 13: connection.Open(); Line 14: SqlCommand command = new SqlCommand("select Image from Image where ImageID="+imageid, connection); Line 15: SqlDataReader dr = command.ExecuteReader(); Line 16: dr.Read(); Line 17: context.Response.BinaryWrite((Byte[])dr[0]);   I am using sqlexpress. Table name is Image with columns ImageID(Identity), ImageName(Varchar(50)) and Image(image). Any help is appreciated.   Juvan   Here is the code;   <%@ WebHandler Language="C#" Class="FullImage" %> using System; using System.Web; using System.Data.SqlClient; using System.Configuration; public class FullImage : IHttpHandler { public void ProcessRequest (HttpContext context) { string imageid = context.Request.QueryString["ImID"

OleDbCommand.ExecuteReader Problem


I am working with a VS 2005 web application that I inherited. The app has a generic data access class to connect to either an Oracle or SQL Server backend. It is currently pointing to an Oracle 10g back-end.

Most data calls are dynamic sql statements build in strings and then passed to the data access class that returns an IDataReader object. Things were working well until we made some updates to the application and are now having regression errors.

The specific error, or lack of error, I am running into involves the OracleDBCommand's ExecuteReader method. When this method fires for a specific sql statement, no data is returned. If I step through the code and pull out the sql from the command, it will return data in my Oracle Developer window. A slightly varied statement (minus one where statement) works in both the app and Oracle Developer.

I tried changing the statement to use the OracleClient equivalents and the datareader worked just fine this time through.

Are there existing issues with the OleDbCommand and the ExecuteReader in connection with Oracle? Any ideas?

Thanks y'all. 

ExecuteReader requires an open and available Connection. The connection's current state is closed.


I am accessing SQL2005 with C# code using  OleDbConnection.


A try and catch block catches the following error once a while between the Open() and Close() of the connection:

ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.


I do not even have any idea where to start to debug this.  The ExecuteNonQuery() runs a delete SQL query. It works 99.9% of the time. I do not see anything wrong when this error happens. 


Any hint would be greatly appreciated.



ExecuteReader problem in web form: Connection-property not initialized


I changed my data source from an access-db to a sql-server, now i still have to fix some problems Undecided

When I want to load a value from a sql-database into my web form (to display a default value), I get an ExecuteReader error ("Connection-property not initialized").

I dont know where to set the connection property in my code.

Dim con As New System.Data.SqlClient.SqlConnection()
Dim myCommand As New System.Data.SqlClient.SqlCommand
Dim SqlCon As String = "Data Source=blablabla\SQLEXPRESS;Initial Catalog=Bill;Persist Security Info=True;User ID=xxx;Password=password"
con.ConnectionString = SqlCon
Dim reader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader() 

The error occurs in the last line. Do I have to set the connection property in the SqlCon string?

Problems with ExecuteReader. No datagrid results returned since reader = nothing


I am having problems with the following. On debugging I find that when strKeywords = '', reader = "System.Data.SqlClient.SqlDataReader". However, as soon as strKeywords takes the value of anything else, reader = nothing. But the stored procedure handles the arguments fine, so I am very confused! Any ideas?

    Public Function RunSearch(ByVal strKeywords As String, ByVal strMediaType As String, ByVal strCamera As String) As Data.DataTable
        Dim AerialConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("aerialConnectionString").ConnectionString)
        Dim dtSearch As New Data.DataTable
        Dim reader As SqlDataReader
            'Opening the connection
            Dim SelectMediaArchiveCommand = New SqlCommand("EXEC spSearchResults @Keywords, @MediaType, @Camera", AerialConnection)
            SelectMediaArchiveCommand.Parameters.AddWithValue("Keywords", strKeywords)
            SelectMediaArchiveCommand.Parameters.AddWithValue("MediaType", strMediaType)
            SelectMediaArchiveCommand.Parameters.AddWithValue("Camera", strCamera)
            reader = SelectMediaArchiveCommand.ExecuteReader()
        Catch e As Exception

Performance: Convert ExecuteDataSet to ExecuteReader


Hai friends,

I am using ExecuteReader() for DataReader
SqlDataReader myReader = _database.ExecuteReader(myCommand);

 and ExecuteDataSet() for DataSet.
DataSet myDataSet = _database.ExecuteDataSet(myCommand);

I read following Microsoft article regarding performance between ExecuteReader() and


It says, ExecuteReader() is better than ExecuteDataSet().

So can I use like
DataSet myDataSet = (DataSet)_database.ExecuteReader(myCommand);

(First I use ExecuteReader and convert as DataSet and assign to DataSet object)

Can I acheive the performance?

What is the advantage and disadvantage of this?

Thank you,

With Regards,



ExceptionCode: 0xc0000005 using SQLCE when ExecuteReader() statement executes


I have this code:

string TmpMakat, TmpIsShakil, TmpDes;

        SqlCeDataReader read;

        public bool LOOK()

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend