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..
That depends on how the table is structured. Do you have an auto increment identity column or a "CreateDate" column you could use?
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.
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
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..
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?