How to display data in datagridview starting from the record which we pass at runtime? In C#
For example, there is 10 rows in a table. When i run the app i'll pass 5th record's value so it should show all data of table starting from 5th row.

hello!
i think u have to post this question in c# forum , well ,if u want if u give the 5th records value and want to show all the records , starting from 5th row , u have to edit ur sql query , check this one

dim da as new sqldataadapter("select * from table1 where recordid => " & val(txtboxvalue .text),ur_connection)
'this will get all the records having recordid greater then or equal to the providing id.
'now this is c# code
SqlDateAdapter da = new SqlDataAdapter("select * from table1 where recordid => " & val(txtboxvalue .text),ur_connection);

after this code populate ur grid ,

Hope this will helps u , If ur prob solved please mark this thread Solved
Regards
M.Waqas Aslam

Hope this will helps u

My query is same. My problem is slightly different. I am using two columns and based on that columns value i want to display data. Means i want restriction also. If i will use AND than it will return only one record and if i will use OR statement than it will return unwanted record also. M very much confused.

@jigs28: I'm also confused, but as to what you are doing and what is the problem. Feel free to start a thread of your own and not hijack a totally different issue. As you seem to have problems with your query (AND & OR I'm guessing go to the query) make sure you include that in your post.

AND will only return one record if there is only one record matching the where clause. If you have multiple rows that match you will get multiple rows back, for example if your table holds the following data

FLD1 | FLD2 | FLD3
XXX | 111 | A
XXX | 111 | B
XXX | 222 | B

and your where clause is

WHERE FLD1='XXX' AND FLD2='111'

then you will have two rows returned

@adam_k: my prblm is
consider Train availability example.
Table contains two fields
TRAIN_NUMBER | DATES
123 | 11/1
123 | 12/1
123 | 13/1
123 | 14/1
123 | 15/1
456 | 11/1
456 | 12/1
456 | 13/1
456 | 14/1
456 | 15/1
now if user wants availability of 13/1 of train 123 than it should return only 3rd, 4th, 5th rows (starting from the date entered by the user.) so here if i will use AND than it will return only 3rd row & if i will use OR than it will return train 456 data also because OR matches any one of true. I think datagridview is the wrong control for this.

Hello Jigs28 !
use this query may b it works for u

select train_number ,dates 
from table1 
where train_number = @train_number and dates>=@dates

this code return all the records of the train 123 from the given date .
Hope this will helps u , if yes please give thumbs up :)

Regards

M.Waqas Aslam

Edited 4 Years Ago by M.Waqas Aslam: n/a

@Waqas Aslam
Thank u so much. :-):-):-)
it wrks fine. Thank u.

This question has already been answered. Start a new discussion instead.