Questions tagged [executereader]

A Microsoft .NET method that sends the `CommandText` to the `Connection` and builds a `SqlDataReader`.

Namespace: System.Data.SqlClient
Assembly: System.Data (in System.Data.dll)

public SqlDataReader ExecuteReader()

Return Value

  • Type: System.Data.SqlClient.SqlDataReader
  • A SqlDataReader object.

http://msdn.microsoft.com/en-us/library/9kcbe65k(v=vs.110).aspx

128 questions
1
vote
2 answers

LinqToSQL and the exception " ExecuteReader requires an open and available Connection."

I have a collection called dbUsers of type IQueryable These are pulled from a linqtosql database context i.e. IQueryable dbUsers = DBContext.Users Calling ToList on this object: IList users =…
iasksillyquestions
  • 5,558
  • 12
  • 53
  • 75
1
vote
2 answers

SQl cmd.ExecuteReader() what does it return

I'm studying ASP.NET. I wondered if cmd.ExecuteReader()'s output could be temporally stored into something, like a temp variable, to later re-use it or alter it. I often use temp variables to store stuff. How can I let a dropbox and a gridview both…
Peter
  • 2,043
  • 1
  • 21
  • 45
1
vote
1 answer

packet of queries - MySQL

is there a way to send packet of queries in 1 query to mysql using c# ? i mean i got 13 selects, they are not related, so cant union them, they get diffrent type of data. Now i got dbconn, 13x select, dbclose, its not a problem when it works over…
Cfaniak
  • 409
  • 8
  • 17
1
vote
0 answers

SQLite Inner Join query in C# not returning any data even though in the DB Browser it does

I am using the following query in C# and it does not return any data (meaning there are 0 rows returned or the first reader.Read() returns false var commandText = "SELECT m.Id, m.LastName, m.FirstName, m.MembershipStartDate as …
user1701907
  • 98
  • 11
1
vote
1 answer

Would executing the SqlCommand be completely moot/redundant, and slow things down?

Thanks to some tips and reminders here, I changed my code from this kludgy mess: try { DataSet dsUsage = new DataSet(); SqlConnection conn = new SqlConnection("SERVER=PROSQL05;DATABASE=platypusdata;UID=duckbill;PWD=poisonToe42;Connection…
1
vote
2 answers

SqlHelper.ExecuteReader() throws an exception when no results found

I have an SqlDataReader that is declared like this: Dim myReader As SqlDataReader myReader = SqlHelper.ExecuteReader(ConnectionString, "storedProcedure1", CInt(myTextBox.Text)) Later I use the results like this: If myReader.HasRows Then While…
1
vote
2 answers

ExecuteReader requires an open connection

I am getting the error: "ExecuteReader requires an open connection" and I know the fix is to add a connection.Open() / connection.Close(). My question pertaining to this error is more for me to understand exactly what happen under the hood. I am…
NKD
  • 1,039
  • 1
  • 13
  • 24
1
vote
1 answer

asp.net, ExecuteReader requires an open and available Connection

I have this code on a method: DataGrid2.DataSource = Show1(Convert.ToInt32(Request.QueryString["Cr"])); DataGrid2.DataBind(); this is the show method that is asigned to the datasource: static SqlConnection sqlConntest = new SqlConnection( …
pyram
  • 925
  • 9
  • 24
  • 43
1
vote
4 answers

How to read specific column and cell in mysql in c#?

I use ExecuteReader to select all (SELECT*) for all field like this string query = "SELECT* FROM tb_patient_information "; if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query,…
Prasetyo Jean
  • 57
  • 2
  • 4
  • 10
1
vote
1 answer

cmd.ExecuteReader() with SQLite is slow but fast in SQLite Manager

I planned to use SQLite as local database. I created a complex Select statement with "group by" and "order by" in SQLite Manager (Firefox AddIn). The query run in about 600 ms in SQLite Manager. In my C# application i've created a SQLiteCommand…
Matti
  • 11
  • 4
0
votes
2 answers

SubSonic InlineQuery returning wrong results with ExecuteAsCollection

Using SubSonic 2.2, I have this query: string q = @"SELECT Media.Id, Media.Title FROM Media WHERE Media.UserId = 7" DAL.MediumCollection matches = new InlineQuery().ExecuteAsCollection(q).Load(); Looping through "matches"…
Arthur Chaparyan
  • 2,015
  • 6
  • 29
  • 35
0
votes
1 answer

How to use the ExecuteReaderAsync method from NReco DbDataAdapter

I'm trying to convert some code that uses NReco.Data to async version of ExecuteReader (ExecuteReaderAsync) but the methods requires many parameters. Any ideas…
0
votes
0 answers

How to resolve KeyNotFoundException for MySql.Data.dll in .NET 2.0 with Maria10.6 version?

Currently, I am using both of .NET 2.0 and .NET 4.0 Framework websites. All Websites are using MySql.Data.dll 6.8.3 ver. I found the reason for 'KeyNotFoundException' from these references that indicate unsupported chatset is the…
CY96
  • 1
  • 1
0
votes
0 answers

How to do select query in C# WCF service in Visual Studio and how to get the returned results?

I'm currently trying to view the details of the table using a given id. I need to use select query to retrieve the data from the database. I tried working with ExecuteNonQuery, but it crashes. After I searched, I found people saying not to use…
Se55
  • 1
  • 2
0
votes
3 answers

asp.net c# ExecuteReader() error

The following code produces an error. dbo.getit works fine when I call it directly on the server. The error occurs at cmd.ExecuteReader() . What am I doing wrong? string user; string pw; SqlDataReader dr = null; SqlConnection conn…
elbillaf
  • 1,952
  • 10
  • 37
  • 73
1 2
3
8 9