Questions tagged [sqldatareader]

Provides a way of reading a forward-only stream of rows from a SQL Server database.

The SqlDataReader is a member of the .NET framework's System.Data.SqlClient family responsible for reading data from a SQL database. The SqlDataReader is created by calling the ExecuteReader() method of the SqlCommand object, instead of directly using a constructor.

While the SqlDataReader is being used, the associated SqlConnection is busy serving the SqlDataReader, and no other operations can be performed on the SqlConnection other than closing it. This is the case until the Close method of the SqlDataReader is called. For example, you cannot retrieve output parameters until after you call Close.

Changes made to a result set by another process or thread while data is being read may be visible to the user of the SqlDataReader. However, the precise behavior is timing dependent.

For optimal performance, SqlDataReader avoids creating unnecessary objects or making unnecessary copies of data. Therefore, multiple calls to methods such as GetValue return a reference to the same object. Use caution if you are modifying the underlying value of the objects returned by methods such as GetValue.

References

MSDN Article

1132 questions
0
votes
2 answers

Limit your use of DataTable

I recently saw this, see below. I got OutofMemoryException when loading 2.5 million records with DataTable. And near the bottom, there is a table.Dispose(). Memory usage: 560Mb! Why use DataTable anyway? public string[] GetIDs() { DataTable…
Toblerone 72
  • 53
  • 1
  • 5
0
votes
1 answer

Getiing multiple resultset from a stored procedure

I have a stored procedure that contains multiple selects a bit like this: select 'Connected' exec DoWork @var1 = 23, @var2 = 400 select 'Done' select 'Bye' When I call the stored procedure from my C# code I only get a single result in my…
CruelIO
  • 18,196
  • 16
  • 40
  • 58
0
votes
1 answer

mysqlexception was unhandled - There is already an open DataReader associated with this Connection which must be closed first

So I am trying to use the form to update my database on xampp. But when I try update I get the error in the title at this part: reader = objcommand.ExecuteReader() All help is much appreciated. Here is the code: Imports MySql.Data Imports…
Livaren
  • 41
  • 1
  • 2
  • 11
0
votes
2 answers

Populate dropdownlist with datareader from database

Problem with populate specific dropdownlist values from database, i want to shows user all the current data from database tables to let them able to make changes, but i coulnd't shows the specific dropdownlist that user selected before. Im using…
user3115280
  • 75
  • 2
  • 2
  • 6
0
votes
2 answers

Login validation for connect to application C#

I created login validation for connect to application but now i have problem that during connecting to app say me that errors with shutdown connections. My script for validation: SQL: CREATE TABLE [Login] ( username varchar(30) CHECK (username…
0
votes
1 answer

Error: You have specified an invalid column ordinal

i'm having an issue loading data from my database to my windows form. I'm using the code below to retrieve the information through a datareader and then set the retrieved information to the appropriate labels and pictureboxes but when the AirSpace…
Noah Cordoba
  • 5
  • 2
  • 8
0
votes
1 answer

MySQLDataReader not loading any data into specified places on form shown

I'm having problems loading information from my database into labels and pictureboxes. I think my code is correct to do what i'm wanting but i'm guessing not since it's not working. Below is the code i'm using. For the picture column in my database,…
Noah Cordoba
  • 5
  • 2
  • 8
0
votes
2 answers

Everything freezes when closing or disposing a reader

I'm having an issue with either the reader being open when I try to use the same connection to add data to the database OR closing or disposing the reader and having the program freeze. If you don't understand what i'm trying to explain, please ask…
Noah Cordoba
  • 5
  • 2
  • 8
0
votes
3 answers

Sqldatareader optional parameter

I have a datareader that is getting results from my stored procedure. The stored procedure depending on certain values such as ("ismarried" = true) returns 10 coulmns but if ("ismarried" = false) it returns only 5 columns. In my asp.net page my…
Tim
  • 1,209
  • 4
  • 21
  • 33
0
votes
1 answer

C# SqlDataReader write multiple rows

I wonder how I could write out my rows, and not the first one only. Here is my c# string SessionID = Session["ID"].ToString(); using (SqlConnection connection = new SqlConnection(@"Data Source=JENSKVIST\SQLEXPRESS;Initial…
Kvist
  • 29
  • 4
0
votes
1 answer

getting many messages of a Table change from data gridview in C#

i made this coding actually find in stuckoverflow :) and i re made it according to my application and changed connection string and tabe name as well as raw name, it is all correct, no more errors before compiling when i have entered have value to…
Moz
  • 39
  • 3
  • 11
0
votes
1 answer

How to populate FormView from SQLDataReader object?

I am new to ASP.NET and C#. I am trying to display some basic information about a "supplier" which is retrieved from a database with a simple query. I started off using a GridView, and it worked perfectly fine, but I like the look of FormView…
tmatti
  • 101
  • 1
  • 5
0
votes
1 answer

Using SqlDataAdapter or SqlDataReader, which one is more efficient and puts minimum load on server?

I am writing an ASP.net C# program, in which I have to do multiple trips to SQL database and for retriving small small data many times. Please suggest which way is more efficent? Should i use SqlDataAdapter and store entire data in DataTable and…
0
votes
3 answers

pass huge data from database layer to presentation layer

I have three layer application in which all database related operation are performed in database layer. for some queries huge data is fetch in sqldatareader (around 10 Millions rows with 32 columns), my question is how i can pass this big data to…
Real Master
  • 347
  • 3
  • 14
0
votes
1 answer

asp.net grid view and dataList

I need help with a part of my website I'm coding. I have a listBox_Products which is populated with sqlServerDataSource. When I click on a product, it will display a corresponding picture along a gridview with productPrice and productName. The…