M
Mark
Hi,
the same application runs independantely on two computers:
the first is an Windows XP prof. sp2 IIS 5.1, dutch version with regional
settings = French (Belgium). So the short date notation is e.g. 13/08/2007.
The date (datetime) in sql server installed on this computer is also
rendered as 13/08/2007.
the second computer is a Windows server 2003 sp2 IIS 6.0, english version
with also regional settings = French (Belgium). So the short date notation
is e.g. 13/08/2007. The date (datetime) in sql server installed on this
computer is also rendered as 13/08/2007.
Sofar no difference.
The application uses a detailsview for showing data and allows updating
data.
The date in the detailsview from the sql server is rendered correctly with
both computers (e.g. 13-08-07 because of the format, see code below).
But now, when clicking on Updating button and the date is e.g. 14-08-07, the
XP computer makes the update without problem, while the server 2003 box
gives the error:"could not convert string to datatime: out-of-range value".
I tried in code-behind with the String.Format("{0:yyyy.MM.dd}", but without
succes
So my questions are:
1) Why does the conversion from a string (data shown in textbox of the
detailsview) to datetime (in sql server) happen properly with XP box and
not with server 2003? The only difference is the language version (dutch for
xp, english for server 2003), but with same regional settings. Are there
different conversion version in function of ... what?
2) what can i do to solve this problem with server 2003?
The code-behind:
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
DetailsView1.ItemUpdating
.....
e.NewValues("datbeg") = String.Format("{0:yyyy.MM.dd}", datbeg)
.....
the aspx file:
<asp:SqlDataSource ....
UpdateCommand="UPDATE [mytable] SET [datbeg] = @datbeg">
<UpdateParameters>
<asparameter Name="datbeg" Type="DateTime" />
</UpdateParameters>
</asp:SqlDataSource>
<aspetailsView ....>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("datbeg",
"{0:dd-MM-yy}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="begin" SortExpression="datbeg">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("datbeg",
"{0:dd-MM-yy}") %>' ></asp:TextBox>
</EditItemTemplate>
....
I have another example of difference:
sql = "select datbeg from mytable"
.....
dtreader.Read()
datb = dtreader.GetDateTime(0).Date
=> with XP: 13/07/2007
=> with server 2003: 7/13/2007 !!!
Thanks for help
Marc
the same application runs independantely on two computers:
the first is an Windows XP prof. sp2 IIS 5.1, dutch version with regional
settings = French (Belgium). So the short date notation is e.g. 13/08/2007.
The date (datetime) in sql server installed on this computer is also
rendered as 13/08/2007.
the second computer is a Windows server 2003 sp2 IIS 6.0, english version
with also regional settings = French (Belgium). So the short date notation
is e.g. 13/08/2007. The date (datetime) in sql server installed on this
computer is also rendered as 13/08/2007.
Sofar no difference.
The application uses a detailsview for showing data and allows updating
data.
The date in the detailsview from the sql server is rendered correctly with
both computers (e.g. 13-08-07 because of the format, see code below).
But now, when clicking on Updating button and the date is e.g. 14-08-07, the
XP computer makes the update without problem, while the server 2003 box
gives the error:"could not convert string to datatime: out-of-range value".
I tried in code-behind with the String.Format("{0:yyyy.MM.dd}", but without
succes
So my questions are:
1) Why does the conversion from a string (data shown in textbox of the
detailsview) to datetime (in sql server) happen properly with XP box and
not with server 2003? The only difference is the language version (dutch for
xp, english for server 2003), but with same regional settings. Are there
different conversion version in function of ... what?
2) what can i do to solve this problem with server 2003?
The code-behind:
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
DetailsView1.ItemUpdating
.....
e.NewValues("datbeg") = String.Format("{0:yyyy.MM.dd}", datbeg)
.....
the aspx file:
<asp:SqlDataSource ....
UpdateCommand="UPDATE [mytable] SET [datbeg] = @datbeg">
<UpdateParameters>
<asparameter Name="datbeg" Type="DateTime" />
</UpdateParameters>
</asp:SqlDataSource>
<aspetailsView ....>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("datbeg",
"{0:dd-MM-yy}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="begin" SortExpression="datbeg">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("datbeg",
"{0:dd-MM-yy}") %>' ></asp:TextBox>
</EditItemTemplate>
....
I have another example of difference:
sql = "select datbeg from mytable"
.....
dtreader.Read()
datb = dtreader.GetDateTime(0).Date
=> with XP: 13/07/2007
=> with server 2003: 7/13/2007 !!!
Thanks for help
Marc