Questions tagged [sqldatareader]

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

sqldatareader
Filter by
Sorted by
Tagged with
1 vote
2 answers
5k views

C# Login screen using sql database not working

I have a simple login screen which, upon user clicking login button, should run the sql query to search for rows where the username == username text box, and password == password text box. This ...
NickB6's user avatar
  • 209
0 votes
1 answer
225 views

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

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 ...
Allon Guralnek's user avatar
1 vote
2 answers
4k views

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 ...
Tamara Caligari's user avatar
-1 votes
2 answers
179 views

Sql Query error asp.net c#

I am using the below code to get results from my table and bind it to a gridview control . But I get the following error: "System.Data.SqlClient.SqlException: Incorrect syntax near 'x'" at "sqlda....
Bilal Ahmed Janjua's user avatar
0 votes
0 answers
80 views

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 ...
j.i.h.'s user avatar
  • 825
3 votes
1 answer
485 views

rename rows in datatable

I currently am working with a database for a 3rd party application that has no form checks for data in the columns I am working with. I am using SqlDataReader (because this does not need to modify the ...
h8a's user avatar
  • 126
0 votes
1 answer
164 views

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 ...
Nicholas Aysen's user avatar
0 votes
1 answer
683 views

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 ...
B. Clay Shannon-B. Crow Raven's user avatar
1 vote
1 answer
2k views

MVC4 Send Datatable to View

I need to pass a list of TestModel into my view. This list will then be used to populate a grid. However, I want the members of TestModel to be created dynamically from headers in a datatable loaded ...
HendPro12's user avatar
  • 1,104
0 votes
1 answer
1k views

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 ...
7alhashmi's user avatar
  • 924
0 votes
1 answer
5k views

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 = '" &...
Hari's user avatar
  • 137
0 votes
1 answer
323 views

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 ...
VPP's user avatar
  • 751
7 votes
4 answers
41k views

Access a specific row in DataReader

I have a datareader to display a list of gameweeks in a js carousel. I need to be able to add an if statement to change the div class of the current gameweek. This is my current code: if (dReader....
JackofAll's user avatar
  • 527
2 votes
2 answers
8k views

Datareader not displaying first row

I am looping through my database to display a list of leagues a player is associated with. If a player is not a member of any leagues then a message displays to tell them. Here is the code if (...
JackofAll's user avatar
  • 527
0 votes
2 answers
301 views

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 ...
user avatar
1 vote
1 answer
931 views

Unable to Make this log in Form in c# / SqlDataReader Issue

I am trying to make a windows Form Application with a login screen,Form3 Will open Form1 if the username and password are correct. The code is linked to a database The code is as follows: private ...
user2040978's user avatar
0 votes
1 answer
654 views

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 = ...
g_shockTan's user avatar
0 votes
1 answer
662 views

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 ...
JackofAll's user avatar
  • 527
0 votes
1 answer
492 views

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 ...
user avatar
6 votes
2 answers
3k views

How to read dynamic properties from database

I will try to explain my scenario the best way I can. I have the following tables in my database: Products{ProductId, CategoryId ...} Categories{CategoryId ...} CategoryProperties{CategoryPropertyId, ...
1110's user avatar
  • 7,809
5 votes
1 answer
19k views

The data types text and varchar are incompatible in the equal to operator

I am trying to access all the records from database on a data grid view depending upon the type of user logging in through a form having 2 text-boxes for user_name and password respectively and on ...
ankita alung's user avatar
3 votes
1 answer
7k views

How to return a temp table from a stored procedure to be used in a C# datareader?

I have the following stored procedure (T-SQL) and I'd like to call it using command.ExecuteReader in C# code so that I can loop through any errors raised OR call it from SQL directly. However, I am ...
BlueChippy's user avatar
  • 6,021
0 votes
3 answers
146 views

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) { ...
1110's user avatar
  • 7,809
3 votes
3 answers
509 views

how to read a sql column containing commas as one field with c#

I have a sql08 database table which I am reading with C#. One of the columns (College) contains data where some data has a comma: Miami, FL or Miami, OH, and some don't: USC. My output .csv shifts ...
krb010301's user avatar
2 votes
3 answers
24k views

SqlDataReader and SqlCommand

I have the following code. using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { connection.Open(); SqlCommand ...
Stuart's user avatar
  • 1,554
3 votes
2 answers
9k views

Out of range error on SqlDataReader

I'm using a SqlDataReader and get this exception when trying to read a column... System.IndexOutOfRangeException: record Here is the code... SqlCommand select = new SqlCommand("SELECT RTRIM(LTRIM(...
Stuart's user avatar
  • 1,554
29 votes
5 answers
55k views

SqlDataReader vs SqlDataAdapter: which one has the better performance for returning a DataTable?

I want to know which one has the better performance for returning a DataTable. Here for SqlDataReader I use DataTable.Load(dr) Using SqlDataReader: public static DataTable populateUsingDataReader(...
Satinder singh's user avatar
2 votes
1 answer
491 views

Why 'IsDBNull' returns false for field that is NULLable in the DB? [closed]

I read data from DB using 'IDataReader' and simple query SELECT * FROM mytable ORDER BY Id The problem is that call to reader.IsDBNull(i) return 'false' even for nullable fields... and call to ...
Budda's user avatar
  • 18.2k
0 votes
2 answers
1k views

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 ...
user2078938's user avatar
-1 votes
3 answers
1k views

Error: Invalid attempt to call Read when reader is closed after the while loop?

Hello i have a method which reads some data from the sql and saves them to arrays. to find out how many rows the sql result has i wrote this: DataTable dt = new DataTable(); dt.Load(rdr);...
Eray Geveci's user avatar
  • 1,099
0 votes
2 answers
4k views

.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 ...
user avatar
1 vote
2 answers
4k views

DataTable.Load() vs. DataReader

Getting large data around 200MB using stored procedure from Database. Previously used DataTable.Load() method to populate this data in DataTable. But it caused a performance issue and the DataTable is ...
phanish m's user avatar
0 votes
1 answer
1k views

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 ...
Thaitan's user avatar
  • 35
0 votes
4 answers
807 views

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 ...
user avatar
1 vote
1 answer
1k views

Create Access Table from SQLDataReader

I am having trouble determining the best way to do this. We are maintaining a complex DB which the average business analyst will have a lot of trouble dealing with. Another developer created a couple ...
BLSully's user avatar
  • 5,939
0 votes
1 answer
821 views

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

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 ...
wmaynard's user avatar
  • 238
0 votes
1 answer
227 views

SqlDataReader Force It To Read One Row At A Time

It appears that SqlDataReader reads ahead while (rdrMainLoop.Read()) { sID = rdrMainLoop.GetInt32(0); nearDupID = rdrMainLoop.IsDBNull(2) ? 0 : rdrMainLoop.GetInt32(2); sqlCmdProducer....
paparazzo's user avatar
  • 44.9k
0 votes
2 answers
4k views

Datareader has rows when loading it to datatable I am getting row count = 0

try { String empid1 = Request.QueryString["MyText"]; int empid = int.Parse(empid1); string constr = System.Configuration.ConfigurationManager....
user1912987's user avatar
4 votes
1 answer
6k views

DataReader cursor rewind

How do I can rewind a cursor of a DataReader to the beginning? With one DataReader result I need to run two while loop, but those have to be from beginning. They are two iterations in one result set ...
DontVoteMeDown's user avatar
0 votes
0 answers
2k views

Getting invalidoperationexception when using an SqlDataReader, why?

This is my code: public List<Remarks1> fillRemarks1List(RemarksRequest oei) { List<Remarks1> mylist = new List<Remarks1>(); SqlConnection sqlConn = new SqlConnection(strConn);...
Testing ur temper's user avatar
0 votes
2 answers
1k views

MVC displaying the row's data to the view

This should be a very easy question as I'm a noob and almost have it figured out myself. I'm authenticating against info in a database and I want to simply display the row's data to the view. I'm ...
Batsu's user avatar
  • 55
1 vote
2 answers
929 views

Listbox and SqlDataReader Issue

I am attempting load employee data from a stored procedure into a listbox in a form load event by ID and assign each with an image. The code above is what I have thus far. So what I'm trying to do ...
Jodie ThatOne Guy Logan's user avatar
24 votes
5 answers
53k views

Should I call SqlDataReader.HasRows if I am calling SqlReader.Read

Trying to see if it is beneficial to add an if (dr.HasRows) before the while (dr.read()) function. I mean, technically if it doesn't have rows it isn't going to read, so would it matter if you checked ...
Joshua Volearix's user avatar
0 votes
2 answers
5k views

How to use SqlDataReader to retrieve information from database, c#

I need to access a variable in my SQL database, along with a username which is already implemented properly. I query the database using this statement: private const string _getUserByUsernameQuery = @...
Nibirue's user avatar
  • 411
1 vote
2 answers
1k views

faster than SqlConnection and SqlDataReader in .net

I use this code: Dim connection As SqlConnection Dim connetionString As String Dim sqlq As String = "select c.* from(..." connetionString = "Data Source=...;Initial Catalog=...;User ID=...;...
babboon's user avatar
  • 753
0 votes
1 answer
45 views

How to add in List with sqldatareader

I am doing a program where i have used a class with 4-5 attributes public class Car { public string Make; public string Model; public int Year; public int Doors; public string ...
Luckyy's user avatar
  • 1,031
3 votes
1 answer
1k views

Closing SqlConnection without Closing SQL reader - can it cause connection Leak

I have been using SQLDataReader for fetchig some data from a db. Once I used Reader with the the connection I am closing the connection only and not the Reader. Do we have any possibility of ...
santhosh's user avatar
7 votes
3 answers
2k views

How to Change Column Name In DataReader In C#?

I have SqlDataReader that gets returned from a ExecuteDataReader statement. All I want is: change some column name in the data reader, just before binding to grid. Here's the situation: First I ...
abianari's user avatar
  • 343
-4 votes
3 answers
1k views

c# data reader change field name before Binding [closed]

I have SqlDataReader that fill with ExecuteDataReader statement. I want to change some column name in DataReader after fill. for example after fill datareader i have two column (A,B) i want to ...
abianari's user avatar
  • 343
2 votes
1 answer
474 views

Unable to sort dropdownlist by price

I want to sort a drop down list by price but it doesn't work. I have the error like the following: Incorrect syntax near '='. Description: An unhandled exception occurred during the execution of the ...
Jazz's user avatar
  • 23

1
14 15
16
17 18
23