Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:59:10+00:00 2026-06-08T01:59:10+00:00

I have a table in SQL Server with columns id, name, address in which

  • 0

I have a table in SQL Server with columns id, name, address in which id is the primary key with auto-increment integer.

I have a form in a winforms application in which I have two buttons:

1 previous
2 next

I want the functionality i.e when I click on previous button, I can fetch the previous row of the selected row from table. Same way when I click on next button, I can get the next row of the selected row….

My form looks like this

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:59:12+00:00Added an answer on June 8, 2026 at 1:59 am

    you can select the top 1 row where row ID is greater/lower than your current Id, so if your Id is 123 you can select for the top 1 (the first) row where ID is greater than 123 without knowing that the following should be 124. same of the previous row.

    because it’s PK the rows should be sorted so you don’t need to add sorting command.
    of course you should take care when asking previous row from the first one, or next after the last.

    declare @CurrentID int = 123;
    select top 1 * from [MyTable] where [MyTable].[ID] > @CurrentID;
    

    Of course you better implement it with cache mechanism to avoid making a database query for every button hit so you can query bunch of rows into your application memory and than go by index to the previous or next item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL table in which some columns, when viewed in SQL Server
I have a SQL Server table which has 625 columns created with different datatypes
I have a table Customer with 2 columns Name and Surname (sql Server 2008).
Using SQL Server 2005 I have a table with the following columns id name
I have 5 columns in my SQL Server 2008 table: id INT name VARCHAR(100)
I have stored my tags in the SQL Server database, TABLE NAME: Tags COLUMNS
I have a Database (SQL Server) with table named 'ProcessData' and columns named 'Process_Name'
I use SQL Server 2008 and have a table with 5 char typed columns.
I have a table with the following columns in SQL Server: MEMBERID, MEMBEREMAIL, FATHEREMAIL,
I have a table with 3 columns ( smallint ) in SQL Server 2005.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.