0

hi,

i need to print the last row of the table in the data grid form .i am using the sql server and c#.net.. i want to print the recently inserted row of the table.. can u tell me the answer..

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by sknake
0

That depends on how the table is structured. Do you have an auto increment identity column or a "CreateDate" column you could use?

0

hi,
i have inserted the record into the database.i need to print the recently inserted record in the datagrid by using datareader. so can u tell me the solution.i am incrementing the no. only.. i am not incrementing the date.

0

Do you want to select "the last record" or "the record you just inserted"? They are different queries.

To get the record you just inserted:

Declare @InvNumber int
Insert Into Invoice (Customer) Values ('Me')
Set @InvNumber = Cast(SCOPE_IDENTITY() as int)

Select *
From Invoice
Where InvNumber = InvNumber

To get the last record:

Select *
From Invoice
Order By InvNumber Desc
0

hi,
thank you very much for sending the reply, i know the sql query.but i want to print the result in data grid .i need the steps. after writing the query ,the result will be printed in data grid.. so tell me the code after sql query..plz..

0

That depends on what language you are programming in. It is likely you posted this message to the wrong forum. This forums is for SQL specific questions.

What language are you using?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.