473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with retrieving data using DataReader C# .NET

6
Hi all,
First of all im not sure if this is the correct section to ask this.

Im using C# .NET

I m trying to populate a gridview using datareader with the following code
Expand|Select|Wrap|Line Numbers
  1. protected void page_load (object sender, System.EventArgs e)
  2.  {
  3.  
  4.         SQLCon.ConnectionString = constr;
  5.         SQLCon.Open();
  6.  
  7.         System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("select distinct f.name, f.address, f.telephone , n.name, w.wrario, e.date from farmakeia f, efimeries e, wraria w, nomos n where e.farmakeia_idfarmakeia = f.idfarmakeia and e.wraria = w.idwraria and f.nomos_idnomos = n.idnomos and n.idnomos='" + FarmakeiaNomosID + "' and date='2011-01-09'", SQLCon);
  8.         System.Data.SqlClient.SqlDataReader dtr = cmd.ExecuteReader();
  9.         dtr.Read();
  10.  
  11.         this.GridView2.DataSource = dtr;
  12.         this.GridView2.DataBind();
  13.  
  14.         dtr.Close();
  15.     }
  16.  
The problem is that it fails to load the first entry.
It retrieves 1 less value than it should.

When im using the same query on sql managment studio it works just fine.

It seems strange to me, i would apriciate any help.
Thank you in advance.
Jan 15 '11 #1
0 1385

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Wm | last post by:
I'm not sure why this isn't working, but it's giving me no output. I have a form which requests email and city to pull up a listing, then Email that address with their password. I'm doing an...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
0
by: pedaammulu | last post by:
Hi, I have put up a page which can help you to understand the workings of how to access SQL data using VB.Net. http://www.vkinfotek.com/datareader.html All info on the page and site is to...
0
by: weird0 | last post by:
I dragged the GridView control and configured its source to using SqlDataSource1 and using a StoredProcedure. When i tested the query by passing a value, it gives the records correctly. The...
0
by: DC01 | last post by:
I have added a new measure successfully into the normal cube. I then add it to the virtual cube and reprocess all cubes. I can browse the normal cube successfully. Then when I try and browse the...
0
by: Newbie19 | last post by:
I am currently design a program that uses a SQL Select statement to pull data from a database. Recently I was informed I need to also pull data from a files on a remote hard drive as well. Two...
3
by: arial | last post by:
Hi all, I am not sure this question will belong to a sql group or .net. but the problem I have is, my data entry forms crashes when some enter a apostrophe character in one of the field. that...
4
by: smartin | last post by:
Hi, I'm having problem retrieving data from an SQL stored procedure. I tried debugging but it wont give a the reason for the error. it just throws an exception after executing cmd.ExecuteNonQuery...
2
by: Prasad | last post by:
Hi, I am creating a stored procedure which contains an output parameter. Though the procedure is getting compiled properly I am not able to execute it from within SQL Server Management Studio and...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.