Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #835
| From | "Tony" <johansson.andersson@telia.com> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | more about timestamp |
| Date | 2011-11-24 11:19 +0100 |
| Message-ID | <4ece237f$0$284$14726298@news.sunsite.dk> (permalink) |
| Organization | SunSITE.dk - Supporting Open source |
One strange thing when I add a timestamp column to a table and then changed
some rows and then made a select in the Server explorer that exist in VS I
didn't see any values in this timestamp column. It showed only this
<Binary> in the timestamp column.
But if I instead used the same select from within SQL Server Management
studio I can see values like 0x0000000000001F43
Can somebody why a select on the timestamp give different result beween
Server explorer and SQL Server Management studio
My next question is when I run the aspx page below that use timestamp like
this as you can see below where ProductId=@ProductID AND
RowTimestamp=@RowTimestamp"
I get run time error saying the following Must declare the scalar variable
"@RowTimestamp".
So how do I define the timestamp parameter RowTimestamp to get rid of this
error ?
After the definition of the following SqlDataSource I made an attempt to fix
read more
<asp:SqlDataSource ID="sourceProductDetails" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString
%>"
SelectCommand="SELECT ProductID, ProductName, UnitPrice,
UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE ProductID = @ProductID"
UpdateCommand = "UPDATE Products SET ProductName = @ProductName,
UnitPrice = @UnitPrice,
UnitsInStock =
@UnitsInStock,
UnitsOnOrder =
@UnitsOnOrder,
ReorderLevel =
@ReorderLevel,
Discontinued = @Discontinued
where ProductId=@ProductID
AND
RowTimestamp=@RowTimestamp"
onupdated="sourceProductDetails_Updated">
<SelectParameters>
<asp:ControlParameter ControlID="ddlProducts" Name="ProductID"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
The first parameter ProductID is fetched from the DropDownList control
ddlProducts so that was easy.
The second RowTimestamp is just to check for concurrency. This mean that is
somebody has changed the record with this ProductID after I fetched this
record from the database then this with not be true
RowTimestamp=@RowTimestamp.
So I have even tried to use these properties ConflictDetection and
OldValuesParameterFormatString but I get the same error
Must declare the scalar variable "@Original_RowTimestamp".
So if I must define this RowTimestamp in the selectParameter tag how should
this be done ?
<asp:SqlDataSource ID="sourceProductDetails" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString
%>"
SelectCommand="SELECT ProductID, ProductName, UnitPrice,
UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued
FROM Products
WHERE ProductID = @ProductID"
UpdateCommand = "UPDATE Products SET ProductName = @ProductName,
UnitPrice = @UnitPrice,
UnitsInStock =
@UnitsInStock,
UnitsOnOrder =
@UnitsOnOrder,
ReorderLevel =
@ReorderLevel,
Discontinued = @Discontinued
where ProductId=@ProductID
AND
RowTimestamp=@Original_RowTimestamp"
onupdated="sourceProductDetails_Updated"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="Original_{0}" >
<SelectParameters>
<asp:ControlParameter ControlID="ddlProducts" Name="ProductID"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
//Tony
Back to comp.databases.ms-sqlserver | Previous | Next — Next in thread | Find similar
more about timestamp "Tony" <johansson.andersson@telia.com> - 2011-11-24 11:19 +0100 Re: more about timestamp Erland Sommarskog <esquel@sommarskog.se> - 2011-11-24 23:44 +0100
csiph-web