 |
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
 | This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

August 11th, 2007, 10:50 AM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Conversion from string to type 'Date' error
Well, I am using this Asp.net 2.0 instant result and I am in chapter 1 page p.26
When I clicked the calender, I get this error
Conversion from string "15 8¿ù 2007" to type 'Date' is not valid.
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")),
CDate(dayShownLabel.Text))
DiaryView.aspx. vb
Line 19
-----------------------------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")), CDate(dayShownLabel.Text))
changeDayCalendar.SelectedDate = CDate(dayShownLabel.Text)
changeDayCalendar.VisibleDate = changeDayCalendar.SelectedDate
If Not IsPostBack Then
entryTextTextBox.Text = mDiaryEntry.EntryText
entryTitleTextBox.Text = mDiaryEntry.EntryTitle
End If
End Sub
|
|

August 11th, 2007, 01:41 PM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I change computer system to US and checked on HTML DailyView.aspx
<%@ Page Language=" VB" AutoEventWireup="false" CodeFile="DayView.aspx. vb" Inherits="DayView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
as you can see That code is EN not other country settings.
Also my server is on US too. I test on local server on my computer and post application to see how's different but the same things happend.
I am living in US but my computer setting was the another country but now I changed it US.
After the changed, I reboot the computer and open the application again and exceute the application but still the same error.
Do you have any other idea?
-----------------------------------------------
Quote:
quote:Originally posted by jellyjune
Well, I am using this Asp.net 2.0 instant result and I am in chapter 1 page p.26
When I clicked the calender, I get this error
Conversion from string "15 8¿ù 2007" to type 'Date' is not valid.
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")),
CDate(dayShownLabel.Text))
DiaryView.aspx.vb
Line 19
-----------------------------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")), CDate(dayShownLabel.Text))
changeDayCalendar.SelectedDate = CDate(dayShownLabel.Text)
changeDayCalendar.VisibleDate = changeDayCalendar.SelectedDate
If Not IsPostBack Then
entryTextTextBox.Text = mDiaryEntry.EntryText
entryTitleTextBox.Text = mDiaryEntry.EntryTitle
End If
End Sub
|
|
|

August 11th, 2007, 01:59 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
The EN in the doctype has no affect on the way the ASP.NET page behaves. Instead, add the following to the <system.web> element of web.config and see if that makes a difference:
<globalization culture="en-US" uiCulture="en-US"/>
If it does, you at least know the problem is related to cultural settings in your system.
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|

August 11th, 2007, 03:44 PM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi, again
<system.web>
<roleManager enabled="true" />
<authentication mode="Forms"/>
<compilation debug="true"/>
<globalization culture="en-US" uiCulture="en-US"/>
</system.web>
I typed in still got the same error.
Also I tried to this one on EditEvent.aspx. vb
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim EventBeingEdited As New DiaryEvent(CLng(Request.QueryString("EventId")))
eventNameTextBox.Text = EventBeingEdited.EventName
eventDescriptionTextBox.Text = EventBeingEdited.EventDescription
dayShownLabel.Text = EventBeingEdited.EventDate.Day & " " & MonthName(EventBeingEdited.EventDate.Month)& " " & EventBeingEdited.EventDate.Year
that codes changed to
dayShownLabel.Text = EventBeingEdited.EventDate.Day & " " & EventBeingEdited.EventDate.Month& " " & EventBeingEdited.EventDate.Year
also this way is not working.
I wonder if I have to change on SQL Database to change date format on
----------------------------------------------------
Quote:
quote:Originally posted by jellyjune
Well, I am using this Asp.net 2.0 instant result and I am in chapter 1 page p.26
When I clicked the calender, I get this error
Conversion from string "15 8¿ù 2007" to type 'Date' is not valid.
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")),
CDate(dayShownLabel.Text))
DiaryView.aspx.vb
Line 19
-----------------------------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
mDiaryEntry = New DiaryEntry(CInt(Session("DiaryId")), CDate[/red](dayShownLabel.Text))
changeDayCalendar.SelectedDate = CDate(dayShownLabel.Text)
changeDayCalendar.VisibleDate = changeDayCalendar.SelectedDate
If Not IsPostBack Then
entryTextTextBox.Text = mDiaryEntry.EntryText
entryTitleTextBox.Text = mDiaryEntry.EntryTitle
End If
End Sub
|
|
|

August 11th, 2007, 03:53 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What do you get when you set the Text of a TextBox on a test page programatically, like this:
txtTest.Text = System.DateTime.Now.ToLongDateString()
where txtTest is a TextBox declared in the markup?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|

August 11th, 2007, 06:04 PM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi again
Protected Sub txtTest_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTest.Load
txtTest.Text = System.DateTime.Now.ToLongDateString()
End Sub
It shows as
Saturday, August 11, 2007This one is not connecting with database
|
|

August 11th, 2007, 06:58 PM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
I just fixed the problem.
This time I copied web.config to that one and my server is working fine.
Thank you
but when I input on text on there,Igot this error
Cannot insert the value NULL into column 'DateChanged', table mydatabasename.dbo.DiaryEntry'; column does not allow nulls. INSERT fails.
The statement has been terminated.
The 'InsertDiaryEntry' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'DateChanged', table 'mydatabase name.dbo.DiaryEntry'; column does not allow nulls. INSERT fails.
The statement has been terminated.
The 'InsertDiaryEntry' procedure attempted to return a status of NULL, which is not allowed. A status of 0 will be returned instead.
Source Error:
Line 162:
Line 163: diaryDBConn.Open()
Line 164: sqlCmd.ExecuteNonQuery()
Line 165: mDiaryEntryId = CLng(sqlCmd.Parameters("@NewDiaryEntryId").Value() )
Line 166:
Quote:
quote:Originally posted by jellyjune
Hi again
?
Protected Sub txtTest_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTest.Load
txtTest.Text = System.DateTime.Now.ToLongDateString()
End Sub
It shows as
Saturday, August 11, 2007This one is not connecting with database
|
|
|

August 11th, 2007, 08:40 PM
|
|
Authorized User
|
|
Join Date: Aug 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
[quote]Originally posted by jellyjune
Hi, again
I just fixed the problem by allow nulls on DiaryEntry table on Datechanged
All seems working fine now.
Thank you for your support and help. It was really nice to know that Book Author is trying to help.
|
|

August 12th, 2007, 02:05 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You're welcome. Glad I could help and glad it's all working now.
Instead of allowing nulls, you're better off setting the "Default value or Binding" to GetDate() in the table designer.
This inserts the current date and time for each record that gets inserted if you don't supply a value for the DateChanged column explicitly.
That is how it's implemented in the database that comes with the book.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|
 |