on GuestBook.aspx page it displays:There are currently no comments for this blog entry.
According to the code , GuesBook.aspx page should also display the messges entered by users.
2. Another thing is , For the time being i deleted these code lines from GuestBook.aspx.vb
because it was giving error that :Globals.EmailUser is not a part of .....(didnt remember )
Try
'Add the comment to the database using CommentManager class function AddComment
GuestbookManager.AddGuestbookEntry(strUserName, txtEmail.Text.Trim, HttpUtility.HtmlEncode(txtCommentText.Text.Trim))
'The EmailUser needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.EmailUser("admin", Membership.GetUser("admin").Email, "New Comment Posted!", txtCommentText.Text.Trim)
Catch ex As Exception
'The SendError needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.SendError("admin", "Error Sending Comment!", "An error was encountered in the btnLeaveComment_Click event while trying to call the AddComment() or EmailUser." & vbCrLf & ex.Message)
End Try
3. You are right i need stored procedure to delete unwanted comments, but right iam worried about
When you create columns in a table in the database, there are properties you can set for each column. These are visible when using SQL Server Management Studio Express.
Sub btnLeaveComment_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles btnLeaveComment.Click
If Page.IsValid
Then
Dim strUserName
As String
If (User.Identity.Name
Is Nothing
Or User.Identity.Name =
"") Then
strUserName = txtUserName.Text.Trim
Else
strUserName = User.Identity.Name
End If
Try
'Add the comment to the database using CommentManager class function AddComment
'The EmailUser needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.EmailUser(
"admin", Membership.GetUser("admin").Email,
"New Comment Posted!", txtCommentText.Text.Trim)
Catch ex As Exception
'The SendError needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.SendError(
"admin",
"Error Sending Comment!",
"An error was encountered in the btnLeaveComment_Click event while trying to call the AddComment() or EmailUser." & vbCrLf & ex.Message)
End Try
'Reset the Add Comment form
i tried compiling without TRY n CATCH in method btnLeaveComment_Click method
then i get this error:
Cannot insert the value NULL into column 'GuestbookID', table 'G:\INETPUB\WWWROOT\PWS1\APP_DATA\PERSONAL.MDF.dbo.GuestBook'; column does not allow nulls. INSERT fails.
The statement has been terminated.
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 'GuestbookID', table 'G:\INETPUB\WWWROOT\PWS1\APP_DATA\PERSONAL.MDF.dbo.GuestBook'; column does not allow nulls. INSERT fails.
The statement has been terminated.
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 28, 2006 09:37 PM|LINK
thanks a lot jeremy for GuestBook tables and stored procedure posts.
i am working on it.
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 05:43 AM|LINK
I did as mentioned by you,but
1. even after entering comments ,
its not able to store in GuestBook table and
on GuestBook.aspx page it displays:There are currently no comments for this blog entry.
According to the code , GuesBook.aspx page should also display the messges entered by users.
2. Another thing is , For the time being i deleted these code lines from GuestBook.aspx.vb
because it was giving error that :Globals.EmailUser is not a part of .....(didnt remember )
Try
'Add the comment to the database using CommentManager class function AddComment
GuestbookManager.AddGuestbookEntry(strUserName, txtEmail.Text.Trim, HttpUtility.HtmlEncode(txtCommentText.Text.Trim))
'The EmailUser needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.EmailUser("admin", Membership.GetUser("admin").Email, "New Comment Posted!", txtCommentText.Text.Trim)
Catch ex As Exception
'The SendError needs to be changed to grab the admin user name from somewhere else.
'This should not be hard coded.
Globals.SendError("admin", "Error Sending Comment!", "An error was encountered in the btnLeaveComment_Click event while trying to call the AddComment() or EmailUser." & vbCrLf & ex.Message)
End Try
3. You are right i need stored procedure to delete unwanted comments, but right iam worried about
Q.
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 05:48 AM|LINK
I see the answer of my Q1
it could not store any messages because i deleted the code line which i mentioned in Q2.
So , i need to solve Q2
jwadsworth
Contributor
2378 Points
542 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 06:25 AM|LINK
Are you using my site code? If so which version?
Extended Personal Site Starter kit
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 06:38 AM|LINK
i am using the current version code ,
and its same as in code posted by you in previous posts .
I have another question:
When u say :
GuestbookID int (make it a primary key and set it as an Identity column)
How to set as Identity column ?
jwadsworth
Contributor
2378 Points
542 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 07:39 AM|LINK
Extended Personal Site Starter kit
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 03:20 PM|LINK
thanks for your reply.
I included the TRY n CATCH blocks in btnLeaveComment_Click method (as seen below)
but then i get 2 compilation errors :
1. EmailUser is not a member of microsoft. visual basic.globals
2.SendError is not a member of microsoft. visual basic.globals
In that case i need to change btnLeaveComment_Click method ?
----------------------------------------------------------------
Protected
Sub btnLeaveComment_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLeaveComment.Click If Page.IsValid Then Dim strUserName As String If (User.Identity.Name Is Nothing Or User.Identity.Name = "") ThenstrUserName = txtUserName.Text.Trim
ElsestrUserName = User.Identity.Name
End If Try 'Add the comment to the database using CommentManager class function AddCommentGuestbookManager.AddGuestbookEntry(strUserName, txtEmail.Text.Trim, HttpUtility.HtmlEncode(txtCommentText.Text.Trim))
'The EmailUser needs to be changed to grab the admin user name from somewhere else. 'This should not be hard coded.Globals.EmailUser(
"admin", Membership.GetUser("admin").Email, "New Comment Posted!", txtCommentText.Text.Trim) Catch ex As Exception 'The SendError needs to be changed to grab the admin user name from somewhere else. 'This should not be hard coded.Globals.SendError(
"admin", "Error Sending Comment!", "An error was encountered in the btnLeaveComment_Click event while trying to call the AddComment() or EmailUser." & vbCrLf & ex.Message) End Try 'Reset the Add Comment formtxtCommentText.Text =
""txtUserName.Text =
""DataList1.DataBind()
End If End Subgridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 04:49 PM|LINK
i tried compiling without TRY n CATCH in method btnLeaveComment_Click method
then i get this error:
Cannot insert the value NULL into column 'GuestbookID', table 'G:\INETPUB\WWWROOT\PWS1\APP_DATA\PERSONAL.MDF.dbo.GuestBook'; column does not allow nulls. INSERT fails.
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.The statement has been terminated.
Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'GuestbookID', table 'G:\INETPUB\WWWROOT\PWS1\APP_DATA\PERSONAL.MDF.dbo.GuestBook'; column does not allow nulls. INSERT fails.
The statement has been terminated.
gridview
Participant
949 Points
400 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 05:30 PM|LINK
now getting this error :
Conversion from type 'DBNull' to type 'Date' is not valid.
jwadsworth
Contributor
2378 Points
542 Posts
Re: GuestBook page in Personal website
Jul 29, 2006 10:24 PM|LINK
Extended Personal Site Starter kit