|
 |
ado_dotnet thread: timestamp in c# question
Message #1 by "ProDevTeam" <ProDevTeam@g...> on Fri, 7 Feb 2003 11:42:59 +0100
|
|
Hi Group
To make sure I get no "lost updates/concurrency problem" in my DB when I
update data, I have
added a timestamp column to each table. Now I want to work with this
timestamp column in my C# source code. To do that I have a method which
connects to the DB and returns a filled dataset. Now I want to exctract
the
timestamp column out of the dataset. But I don=B4t know how to exactly
do
this. For simple datatypes (string,int...) I have a method which returns
the
result as string
------cut---------------------------
foreach(DataTable myTables in DataSet.Tables)
{
foreach(DataRow myRow in myTables.Rows)
{
foreach (DataColumn myColumn in myTables.Columns)
{
if(columnname =3D=3D myColumn.ToString().ToLower())
{
valueFound =3D myRow[myColumn].ToString();
}
}
}
}
-------------cut--------------------------------------
When I use this method my string is converted in a byte array. But the
byte
array is always the same, even if i run an update against the selected
data.
My problem is I don=B4t know/ find another way to get the data out of
the
dataset. Can anyone help me?
regards
Bj=F6rn
Message #2 by "Brian Smith" <bsmith@l...> on Fri, 7 Feb 2003 12:17:53 -0000
|
|
A timestamp column is not intended for interpretation - it=92s a long
number based on the time, and guaranteed unique by the server. If you
want to treat it as time, then use a datetime column. Unless you have a
very high transaction rate, this will perform the same function with
addition of giving useful information.
As for your iteration, it looks enormously exensive if all it does is
identify a single column value: what's wrong with
DataSet.Tables["myTable"].Rows[myRow]["myColumn"]?
brian
-----Original Message-----
From: ProDevTeam [mailto:ProDevTeam@g...]
Sent: Fri, 07 Feb 2003 10:43
To: ADO.NET
Subject: [ado_dotnet] timestamp in c# question
Hi Group
To make sure I get no "lost updates/concurrency problem" in my DB when I
update data, I have added a timestamp column to each table. Now I want
to work with this timestamp column in my C# source code. To do that I
have a method which connects to the DB and returns a filled dataset. Now
I want to exctract the timestamp column out of the dataset. But I
don=B4t
know how to exactly do this. For simple datatypes (string,int...) I have
a method which returns the result as string
------cut---------------------------
foreach(DataTable myTables in DataSet.Tables)
{
foreach(DataRow myRow in myTables.Rows)
{
foreach (DataColumn myColumn in myTables.Columns)
{
if(columnname =3D=3D myColumn.ToString().ToLower())
{
valueFound =3D myRow[myColumn].ToString();
}
}
}
}
-------------cut--------------------------------------
When I use this method my string is converted in a byte array. But the
byte array is always the same, even if i run an update against the
selected data. My problem is I don=B4t know/ find another way to get the
data out of the dataset. Can anyone help me?
regards
Bj=F6rn
=3D=3D=3D
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003
|
|
 |