none
Data Access from SQL Server 2000 RRS feed

  • Question

  • Hi. I’m using VB .net windows form and MS SQL Server 2000 personal edition. I have created a table “candidate” in SQL Server with 14 fields and of which ID and SDATE are two fields. Their data types are as follows.

    ID- varchar(10), not null – contains values 0 to 9 but in string format
    SDATE – datetime, not null – contains server system date in mm/dd/yyyy hr:minTongue Tiedec format

    The sample table fields are as follows
    ID                         SDATE
    1006200701         6/10/2007 20:54:56
    1006200702         6/10/2007 22:43:23
    1406200701         6/14/2007 12:22:40
    1506200701         6/15/2007 10:45:34
    1506200702         6/15/2007 11:00:02
    .
    .
    I want to read the last ID entered in the table with the help of SDATE and store it in a String type variable in VB net code. I want to use inline queries from VB net code. So what would be the code for it?

    Tuesday, June 19, 2007 5:59 PM

Answers

  • I think the query you're looking for is:

       SELECT ID FROM MyTable WHERE SDATE = (SELECT MAX(SDATE) FROM MyTable)
    Tuesday, June 19, 2007 6:21 PM

All replies

  • I think the query you're looking for is:

       SELECT ID FROM MyTable WHERE SDATE = (SELECT MAX(SDATE) FROM MyTable)
    Tuesday, June 19, 2007 6:21 PM
  • Thank you. The query works from MS SQL server Query analyzer. But I want to store the result (ID) in a String variable in VB .net  code using Inline query. Then what should be the code for that?
    Tuesday, June 19, 2007 6:59 PM