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
1 answer

No results returned to a reader but the same query works thru SQL Management Studio

I'm experiencing weird behavior with some of full text search queries, especially those with multiple words. These are working fine when executed thru Management Studio but returning no results when called from a code. I did a SQL Trace to see what…
Antonin Jelinek
  • 2,277
  • 2
  • 20
  • 25
0
votes
1 answer

How can I tell if my SqlCeDataReader contains any vals after calling SqlCeCommand.ExecuteReader()?

With the code below: SqlCeDataReader myReader = cmd.ExecuteReader(CommandBehavior.SingleRow); itemID = myReader.GetString(0); packSize = myReader.GetString(1); ...I get an exception, "No data exists for the row/column" I want it to silently "abort"…
0
votes
1 answer

SqlDataReader Convert byte to integer vb.net

I am trying to retrieve the information from a database table using SqlDataReader. I have two columns one string and the other is bit. The string will be filled in a textbox. But the problem with the bit when I wanted to fill it on a radiobuttonlist…
7alhashmi
  • 924
  • 7
  • 24
0
votes
1 answer

already an open DataReader associated with this Command when am chekcing with invalid data

Private Sub txt_sname_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt_sname.GotFocus Dim fcs As String fcs = "select fname,dept from nstudent where stid = '" & txt_sid.Text & "'" scmd1 = New…
Hari
  • 137
  • 3
  • 5
  • 14
0
votes
1 answer

Issues with writing BLOB data in chunk (8k)

I'm trying to write BLOB data on to a word file. Here is my code Dim reportID As Integer reportID = table1.report_output_data_id Dim aSqlStr As String = "SELECT file_data FROM table2 WHERE report_output_data_id = " +…
VPP
  • 731
  • 1
  • 9
  • 34
0
votes
2 answers

Building my own SqlDataReader object

I need some help. I've been back and forth on which direction I should go and there are some options of which none I like or can use. I wrote a generic data dump tool that pulls data from a specified server and dumps it to a comma delimited file. …
Chizl
  • 2,004
  • 17
  • 32
0
votes
1 answer

ASP.Net VB SqlDataReader Format

I have a SqlDataReader that reads data from the database. How can I format the phone number to return as (123) 456-7890 instead of 1234567890 on my aspx page? My reader as follow: txtFaxPhone.Text = reader("FaxPhone").ToString()
g_shockTan
  • 325
  • 2
  • 8
  • 15
0
votes
1 answer

Using a literal to display results from query

I'm trying to display multiple rows from a query into a literal in asp.net c#. Here is my code for doing so: protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new…
JackofAll
  • 517
  • 4
  • 13
  • 23
0
votes
1 answer

Alternative to Recordset Looping

Back in the day using ADO, we used GetRows() to pull back an array and loop through it, because it was faster than using rs.MoveNext to walk through records. I'm writing an application that pulls back half a million rows and writes them out into a…
Chizl
  • 2,004
  • 17
  • 32
0
votes
3 answers

Issue with calling two methods in data access method

I have this method: public bool ActivateUser(string username, string key) { var user = this.GetUser(username, true); if (user != null) { if (user.NewEmailKey == key) { …
1110
  • 7,829
  • 55
  • 176
  • 334
0
votes
2 answers

Removing duplicates from an array populated by a reader

I have a database column that has several names separated by commas in each row. I'm trying to populate a data-table containing all the names but without duplicates. Currently the list populates but duplicate names still appear. My code is: while…
user2078938
  • 947
  • 1
  • 9
  • 22
0
votes
2 answers

.NET MySQL Data Reader Select Function?

It has been a long time since I have used .NET, but thankfully have almost finished writing a tool to compare an sqlite and mysql database. I am running into an issue though when trying to write a function for my wrapper that will handle SELECT…
user470760
0
votes
1 answer

Retrieve data using DataReader from multiple tables in mySQL

How would I retrieve the data from the 'DAILY_CALCULATIONS' table Dim SqlQuery As String = "SELECT WEEKLY_TIMECARD.*,DAILY_CALCULATIONS.*,EMPLOYEE_PROFILES.EMPLOYEE_NUMBER " SqlQuery = SqlQuery + " FROM WEEKLY_TIMECARD, DAILY_CALCULATIONS,…
Thaitan
  • 35
  • 1
  • 2
  • 6
0
votes
4 answers

Proper populating of dropdown list in asp.net dynamically

I am a newbie in asp.net, I want to ask what is more proper in terms of populating the dropdown list in asp.net? using a Datasource or using a sqldatareader and a for loop. I am using the sqldatareader and a for loop, here is my sample code: For i…
user1987631
0
votes
1 answer

Slow, Large SQL Query from C# / ASP.NET

Possible Duplicate: How to efficiently write to file from SQL datareader in c#? I am currently trying to create a web application that uses read-only access to allow users to download large files from our database. The table in question has…
wmaynard
  • 238
  • 1
  • 3
  • 12