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

asp repeater populated with datatable not displaying

I'm trying to use a asp repeater for the first time. I used the following tutorial as a guide: http://www.sitepoint.com/asp-net-repeater-con My problem is that the asp repeater is not showing on the page. not even the header or footer. As seen…
T3.0
  • 446
  • 1
  • 6
  • 21
0
votes
3 answers

Performance Concerns between DataTable and SqlDataReader to fill Data with FlexGrid

Which one is more faster between DataTable and SqlDataReader while I'm trying to fill Data into FlexGrid with VB.NET?
RedsDevils
  • 1,413
  • 9
  • 26
  • 47
0
votes
0 answers

SqlDataReader does not update value for column

I have a stored procedure running on SQL Server 2008 that returns a list of all procedures and their parameters: procedure [dbo].[p_ListProcedures] as select sp.name as 'Procedure', p.name as 'Parameter', t.name as 'Type', p.is_output as…
0
votes
2 answers

SqlDataReader.Read Not Working As Advertised?

So I'm running a query in ADO.NET that I know returns a single row. The relevant portion of my code looks like: SqlCommand sqc = new SqlCommand(); sqc.Connection = new SqlConnection("connection string"); sqc.CommandText = "SELECT A, B FROM C WHERE…
user800576
0
votes
2 answers

C# WinForm - Compare DataReader w/ Listbox Contents and Display the Matches

I am attempting to tackle a project where I am pulling a column of data from an SQL database and comparing the data with values within a listbox. So far, it is finding a comparison, but is only returning one value, even with multiple matches in the…
InnerMB
  • 11
  • 2
0
votes
2 answers

VB.net / C# dont reference sqlreader in client portion then where?

Assume I have a form that has say 5 text boxes and I need to pull some data from a database then set those 5 text boxes with that data. So assume I have 3 basic layers: the code behind for a default.aspx page a BLL class that contacts the DAL and…
user192059
  • 41
  • 2
0
votes
1 answer

ASP.Net VB Check if datas exist in database

How do I check if data existing in the database or is NULL. I'm getting the following error Object cannot be cast from DBNull to other types . Do I need to add IsDBNULL to the code? SignedOn.Text =…
g_shockTan
  • 325
  • 2
  • 8
  • 15
0
votes
1 answer

SqlDataReader isn't working, it skips the part where it checks the username

I am working on a project that has 1 client and 1 server. I created also a Class library in which I put the code and than ad this class library as Reference at the Server and at the Client. And so I call methods from the Client by creating an object…
0
votes
3 answers

SelectCommand.Connection is not initialized

I'm trying to access my database, from this method in my DataBaseOptions class. I'm using this with ASP.NET for web development. Whenever I run this method, In another class, I get following error: SelectCommand.Connection is not initialized And…
Kevin Jensen Petersen
  • 423
  • 2
  • 22
  • 43
0
votes
1 answer

ASP.NET Read individual values from a custom seperated row in database

I store values that i save through a form in a database column named 'Properties' like: value1#||#value2#||#value3#||#value4 The question is how to retrieve for example 'value2' from this string when using 'For Each row As DataRow In…
Marcellino Bommezijn
  • 2,889
  • 1
  • 16
  • 14
0
votes
1 answer

How can I set the variable type with an if/then statement in c#?

I have a function which performs an SQL query. Depending on a registry value, it will either hit SQL Server or SQL Server Compact Edition. If it is using SQL Server CE, the line setting the recordSet variable should read like this: SqlCeDataReader…
Progger
  • 2,266
  • 4
  • 27
  • 51
0
votes
1 answer

NHibernate's equivalent of LINQ to SQL's and EF's Translate()

I have a query that due to performance reasons I need to craft the actual command using raw ADO.NET (it involves table-valued parameters). With LINQ to SQL or EF, I could simply pass the DbDataReader that was returned by DbCommand.ExecuteReader() to…
Allon Guralnek
  • 15,813
  • 6
  • 60
  • 93
0
votes
2 answers

SQLDataReader Invalid object name

I am trying to authenticate a user through a login form by reading user details from my database UsersDB. On attempting to read, I get an error: Invalid object name: UsersDB I got no errors when adding a new user to the database so I do not know why…
Tamara Caligari
  • 479
  • 3
  • 12
  • 28
0
votes
0 answers

Unwanted Exception squelching during VS2008 debugging

Is there a way to force SqlDataReader to throw exceptions? There seems to be a very problematic behavior with it where SqlDataReader will have an exception and cause the function it's in to end prematurely without throwing an exception,…
j.i.h.
  • 815
  • 8
  • 29
0
votes
1 answer

No data is read in SqlReader Invalid attempt to read when no data is present.

I know this problem has been posted millions of times before, but this might be different. I am using a sql table with columns id,year,month,pdffile in my webpage, I would like the user to view the pdf document that they would like to see from what…
Nicholas Aysen
  • 568
  • 3
  • 18
  • 40