how do i get a SQL timestamp into/out of a grid?

C

Craig G

i have a hidden template column that contains a label which is populated
with a SQL Timestamp. the problem is each time i bring the timestamp out it
is coming out as "System.Byte[]" which is just a string

i understand that the timestamp cannot be seen as its binary but what/how am
i meant to store it in within the grid and then return it out if the user
selects that particular record

ive just been using this to return other fields but that wont work for the
timestamp
myTimeStamp = CType(e.Item.Cells(5).Controls(1), Label).Text

anyone any idea's?

Cheers,
Craig
 
G

Guest

The timestamp column is not really designed to be a human friendly field. It
is useful in concurrency management, if you design your own, and has other
uses, as well. If you want to display as a numeric value, try something like:

for(int i=timestamp.Length;i>0;i--)
{
result += (byt[i-1] * calc);
calc *= 256;
}

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
This will calculate the value of all of the bytes in the array. Then display
result.ToString();
 
B

bruce barker

'* store in field
CType(e.Item.Cells(5).Controls(1), Label).Text.Text =
System.ConvertToBase64String(myTimeStamp)

'* fetch from field
myTimeStamp = System.ConvertFromBase64(CType(e.Item.Cells(5).Controls(1),
Label).Text)

-- bruce (sqlwork.com)

| i have a hidden template column that contains a label which is populated
| with a SQL Timestamp. the problem is each time i bring the timestamp out
it
| is coming out as "System.Byte[]" which is just a string
|
| i understand that the timestamp cannot be seen as its binary but what/how
am
| i meant to store it in within the grid and then return it out if the user
| selects that particular record
|
| ive just been using this to return other fields but that wont work for the
| timestamp
| myTimeStamp = CType(e.Item.Cells(5).Controls(1), Label).Text
|
| anyone any idea's?
|
| Cheers,
| Craig
|
|
 
C

Craig G

"The timestamp column is not really designed to be a human friendly field" -
i doubt they could make it anymore unfriendly!!


anyhow, when i do the following i get an error saying - Value of type
'String' cannot be converted to '1-dimensional array of Byte'.

myTimeStamp = Convert.ToBase64String(CType(e.Item.Cells(5).Controls(1),
Label).Text)
 
C

Craig G

opps

should read
myTimeStamp = Convert.FromBase64String(CType(e.Item.Cells(5).Controls(1),
Label).Text)

but i still get the 1-dimensional array of byte cannot be converted to
string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top