473,396 Members | 1,765 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,396 software developers and data experts.

MYSQL data fetching error using limit

donilourdu
hi,
I am trying to retrive data from MYSQL database.I am using limit to fetch the data.It will fetch two rows instead of fetching ten rows.But when i try to debug it fetches eight rows instead of ten rows.The codes are given below for your reference.
Expand|Select|Wrap|Line Numbers
  1. private void data(string slimit,string elimit)
  2. {
  3. MySqlConnection conn = new MySqlConnection(ss);
  4. conn.Open();
  5. try
  6. {
  7. MySqlCommand cmd = new MySqlCommand("select iddocument from document_info where scanby is not null limit " + slimit + "," + elimit + ";" , conn);
  8. //cmd.Parameters.Add("?iddocument", MySqlDbType.VarChar).Value = aa;
  9. MySqlDataReader myread;
  10. myread = cmd.ExecuteReader();
  11. while (myread.Read())
  12. {
  13. f.log_insert(myread.GetString(0));
  14. }
  15. myread.Close();
  16. myread.Close();
  17. }
  18. catch (Exception ex)
  19. {
  20. MessageBox.Show(ex.Message);
  21. }
  22. finally
  23. {
  24.  conn.Close();
  25. }
With Regards,
Doni
May 9 '09 #1
11 3587
NeoPa
32,556 Expert Mod 16PB
Doni,

I'm confused. Should this be in the Access forum? This doesn't look like VBA code at all.

If you can say where this should be then I can move it there for you.
May 11 '09 #2
Denburt
1,356 Expert 1GB
Looks like Javascript to me.
May 13 '09 #3
NeoPa
32,556 Expert Mod 16PB
I'll move it there pro tem.
May 13 '09 #4
dlite922
1,584 Expert 1GB
@Denburt
"public void " is JavaScript? its Java!

Java != JavaScript ... not even close.

OP,

I think you may be having trouble with understanding how the LIMIT function works.

In MySQL the first parameter is the number of the record to START from, the second is how many to display from there.

If you have ten records and said LIMIT 5,3 you would get record number 5 through 8. If you said LIMIT 10,10 you would get only one because counting from 10 there's only one record left (ie there is no 11,12,13...20)

If you're doing this for a pagation the first parameter should be page_number-1 * items_perPage.

so in your code subtract one from string, multiply it by estring and put this result as the first parameter and the number of records to display on a page as the second parameter.

Hope that makes enough sense. Try running some queries without code, from command line or the client to test it out.



Dan
May 13 '09 #5
NeoPa
32,556 Expert Mod 16PB
Dan,

We're not from the dark-side you know. How you play with your coffee is your business.

Java / Javascript / whatever. They're all foreign languages to us over in Access. We would care, but you guys seem to have that well covered so why bother :D

I'll move it to Java for you.
May 13 '09 #6
Denburt
1,356 Expert 1GB
LOL actually it says "private void" I missed that, at a quick glance thats what it appeared to be. I am also quite well aware that Java != JavaScript ... not even close. Thank you
May 13 '09 #7
Markus
6,050 Expert 4TB
I have £20 on it being C#. Any more bets?

Also, C# != Java != Javascript .. not even close ;)
May 14 '09 #8
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. MessageBox.Show(ex.Message);
Yep, it's C# alright.
May 14 '09 #9
@donilourdu
I solved the issue
Jun 21 '10 #10
NeoPa
32,556 Expert Mod 16PB
I'm pleased to hear it Doni.

Perhaps you wouldn't mind posting your solution now you have one.
Jun 21 '10 #11
@NeoPa
Denburt is correct. I wrongly undestand the concepts. Extremly sorry man for so much of delay.
Jul 1 '10 #12

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

Similar topics

0
by: Philip Stoev | last post by:
Hi all, Please tell me if any of this makes sense. Any pointers to relevant projects/articles will be much appreciated. Philip Stoev http://www.stoev.org/pivot/manifest.htm ...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
0
by: David List | last post by:
I am wondering what I miss to be able to handle binary data from the mysql client. I have ensured that the user has file_priv set to 'Y' and that max_allowed_packet is larger that the binary lumps...
1
by: jlee | last post by:
I'm pretty much a newbie on mysql, and I need some help. I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4 (i386) on a server hosting an active website. The site's developer...
1
by: Ike | last post by:
Recently, I began using a different MySQL verver (i.e. different machine as well as different version#, going from 4.12a to 4.1.9 max). The following query used to work: select firstname,...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
1
by: spatro | last post by:
Hi, I am trying to install DBD::mysql using the CPAN and I am facing the following error: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Warning:...
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.