Bringing a Timestamp into a recordset

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Re: Bringing a Timestamp into a recordset

    Timestamp isn't really "data" ... it is just a binary rowversion. What are
    you trying to gain by displaying it on the page?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
    news:ebOEGDN9DHA.2604@TK2MSFTNGP10.phx.gbl...
    > Hi Guys
    >
    > The subject of this post might be misleading, but basically I have created
    a
    > basic query ASP page that will allow a user to copy and paste their SQL
    > query into a textbox so that they can execute it on their SQL DB to bring
    > back the result.
    >
    > Now I understand how to dynamically bring back the relevant data cols and
    > rows, but the only bit that I fall foul on is if the user has done a
    select
    > * from a table and brings back a timestamp field.
    >
    > For some reason when my recordset tries to display this timestamp it blows
    > up, which is unlike say MS Query that displays the figure.
    >
    > Is there a special encapsulating command that I have to wrap the recordset
    > in so that it can handle the displaying of timestamps?
    >
    > Rgds
    >
    > Laphan
    >
    >

    Aaron Bertrand - MVP Guest

  2. Similar Questions and Discussions

    1. Bringing xml data into flash
      I would like to know how to bring xml data into flash. Specifically images that someone can click on the thumbnail and view the larger image. please...
    2. int4 -> unix timestamp -> sql timestamp; abstime?
      Hello, what is the opposite of cast(extract('epoch' from now()) as int)? The only thing I found that works is cast(cast(... as abstime) as...
    3. bringing 3d to director
      I was wondering how if i create something in 3d studio max do i bring it into director and then make it so i could make like say a box naviagte...
    4. Bringing XML Data into FMP
      I am in the midst of figuring out how to integrate RF-ID into FileMaker. For those who are not familiar with RD-ID, it is the technology that will...
    5. RecordSet.Move or RecordSet.AbsolutePosition??
      Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to...
  3. #2

    Default Bringing a Timestamp into a recordset

    Hi Guys

    The subject of this post might be misleading, but basically I have created a
    basic query ASP page that will allow a user to copy and paste their SQL
    query into a textbox so that they can execute it on their SQL DB to bring
    back the result.

    Now I understand how to dynamically bring back the relevant data cols and
    rows, but the only bit that I fall foul on is if the user has done a select
    * from a table and brings back a timestamp field.

    For some reason when my recordset tries to display this timestamp it blows
    up, which is unlike say MS Query that displays the figure.

    Is there a special encapsulating command that I have to wrap the recordset
    in so that it can handle the displaying of timestamps?

    Rgds

    Laphan


    Laphan Guest

  4. #3

    Default Re: Bringing a Timestamp into a recordset

    Not trying to gain anything. Because users may enter 'select * from XXX', I
    wanted to format/trap the timestamp so that at least they wouldn't bomb the
    page, which is what happens everytime a timestamp is involved in a query.

    Rgds

    Laphan

    Aaron Bertrand - MVP <aaron@TRASHaspfaq.com> wrote in message
    news:OZg2EFN9DHA.1672@TK2MSFTNGP12.phx.gbl...
    Timestamp isn't really "data" ... it is just a binary rowversion. What are
    you trying to gain by displaying it on the page?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
    news:ebOEGDN9DHA.2604@TK2MSFTNGP10.phx.gbl...
    > Hi Guys
    >
    > The subject of this post might be misleading, but basically I have created
    a
    > basic query ASP page that will allow a user to copy and paste their SQL
    > query into a textbox so that they can execute it on their SQL DB to bring
    > back the result.
    >
    > Now I understand how to dynamically bring back the relevant data cols and
    > rows, but the only bit that I fall foul on is if the user has done a
    select
    > * from a table and brings back a timestamp field.
    >
    > For some reason when my recordset tries to display this timestamp it blows
    > up, which is unlike say MS Query that displays the figure.
    >
    > Is there a special encapsulating command that I have to wrap the recordset
    > in so that it can handle the displaying of timestamps?
    >
    > Rgds
    >
    > Laphan
    >
    >



    Laphan Guest

  5. #4

    Default Re: Bringing a Timestamp into a recordset

    "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
    news:ebOEGDN9DHA.2604@TK2MSFTNGP10.phx.gbl...
    > Hi Guys
    >
    > The subject of this post might be misleading, but basically I have
    created a
    > basic query ASP page that will allow a user to copy and paste their
    SQL
    > query into a textbox so that they can execute it on their SQL DB to
    bring
    > back the result.
    >
    > Now I understand how to dynamically bring back the relevant data cols
    and
    > rows, but the only bit that I fall foul on is if the user has done a
    select
    > * from a table and brings back a timestamp field.
    >
    > For some reason when my recordset tries to display this timestamp it
    blows
    > up, which is unlike say MS Query that displays the figure.
    >
    > Is there a special encapsulating command that I have to wrap the
    recordset
    > in so that it can handle the displaying of timestamps?
    As Aaron pointed out, rowversion data is stored as binary(8). As such,
    you have two options:

    1. Test the data type and omit it's display if it is binary data. I
    believe rowversion data is delivered as an array of bytes. As such you
    would first test to see if the data was an array. Then check if the data
    type of the array elements is a byte.

    2. To actually display the data you will need to convert the data to a
    string of some sort. I would recommend converting the data to a
    hexadecimal string representation.

    The "howto's" of working with binary data can be found here:
    [url]http://www.pstruh.cz/tips/detpg_BinASP.htm[/url]

    HTH
    -Chris Hohmann


    Chris Hohmann Guest

  6. #5

    Default Re: Bringing a Timestamp into a recordset

    > Not trying to gain anything. Because users may enter 'select * from XXX'

    No, no, no. Don't EVER let users enter 'SELECT * from ANYTHING. Ever.
    Period.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand [MVP] Guest

  7. #6

    Default Re: Bringing a Timestamp into a recordset

    Aaron

    I understand your comments regarding select *'s, but I would rather trap the
    timestamp to make the page more robust than limit the simplicity and
    functionality of what I'm trying to achieve with this.

    Many thanks to you and Chris for your feedback.

    Rgds Robbie

    "Chris Hohmann" <nospam@thankyou.com> wrote in message
    news:eCa0Nhb9DHA.3880@TK2MSFTNGP11.phx.gbl...
    "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
    news:ebOEGDN9DHA.2604@TK2MSFTNGP10.phx.gbl...
    > Hi Guys
    >
    > The subject of this post might be misleading, but basically I have
    created a
    > basic query ASP page that will allow a user to copy and paste their
    SQL
    > query into a textbox so that they can execute it on their SQL DB to
    bring
    > back the result.
    >
    > Now I understand how to dynamically bring back the relevant data cols
    and
    > rows, but the only bit that I fall foul on is if the user has done a
    select
    > * from a table and brings back a timestamp field.
    >
    > For some reason when my recordset tries to display this timestamp it
    blows
    > up, which is unlike say MS Query that displays the figure.
    >
    > Is there a special encapsulating command that I have to wrap the
    recordset
    > in so that it can handle the displaying of timestamps?
    As Aaron pointed out, rowversion data is stored as binary(8). As such,
    you have two options:

    1. Test the data type and omit it's display if it is binary data. I
    believe rowversion data is delivered as an array of bytes. As such you
    would first test to see if the data was an array. Then check if the data
    type of the array elements is a byte.

    2. To actually display the data you will need to convert the data to a
    string of some sort. I would recommend converting the data to a
    hexadecimal string representation.

    The "howto's" of working with binary data can be found here:
    [url]http://www.pstruh.cz/tips/detpg_BinASP.htm[/url]

    HTH
    -Chris Hohmann



    Astra Guest

  8. #7

    Default Re: Bringing a Timestamp into a recordset

    Astra wrote:
    > Aaron
    >
    > I understand your comments regarding select *'s, but I would rather
    > trap the timestamp to make the page more robust than limit the
    > simplicity and functionality of what I'm trying to achieve with this.
    >
    Lazy. You are impacting the performance of your application.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  9. #8

    Default Re: Bringing a Timestamp into a recordset

    > Lazy. You are impacting the performance of your application.

    Not to mention security... why should end users know, or even have to know,
    the structure of your table(s)?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand - MVP Guest

  10. #9

    Default Re: Bringing a Timestamp into a recordset

    Understood.

    Thanks Laphan

    Aaron Bertrand - MVP <aaron@TRASHaspfaq.com> wrote in message
    news:uiqtcDj9DHA.2608@TK2MSFTNGP10.phx.gbl...
    > Lazy. You are impacting the performance of your application.
    Not to mention security... why should end users know, or even have to know,
    the structure of your table(s)?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    Laphan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139