Please help me, I've done everything there is to try and fix the error
and I don't know what else to do. The error is SYNTAX ERROR IN UPDATE
STATEMENT.
Here's the .aspx
<code>
<%@ Page Language="
vb" Src="approve.
vb" Inherits="Approve" debug="true"
trace="true" %>
<html>
<Head>
<title>Dot.Net Guestbook - Approve Comments</title>
<style rel="stylesheet">
.name { font-size: 10px; font-family: Arial, Helvetica, sans-serif; }
.comment { font-size: 12px; font-family: Arial, Helvetica,
sans-serif; }
.customersHead { font: bold 8pt Verdana, Arial, sans-serif;
background-color:#4A3C8C; color:white; }
a { text-decoration:underline; }
a:hover { text-decoration:underline; color:#4A3C8C; }
.button { font-size: 9px; font-family: Arial, Helvetica, sans-serif;
}
</style>
</HEAD>
<body>
<form runat="server" id="form1">
<asp:Datalist id="dtlComments"
runat="server"
width="560"
borderWidth="1"
HeaderStyle-CssClass="customersHead"
AlternatingItemStyle-BackColor="#99CCFF"
Font-Size="10"
Align="center"
OnEditCommand="dtlComments_Edit"
OnUpdateCommand="dtlComments_Update"
OnCancelCommand="dtlComments_Cancel">
<itemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="160" class="name"><%#
DataBinder.Eval(Container.DataItem, "name") %></td>
<td width="400" class="comment"><%#
DataBinder.Eval(Container.DataItem, "comment") %></td>
<td width="100"><asp:button id="btnEdit" Runat="server"
class="button" CommandName="edit" Text="Edit Comment" /></td>
</tr>
</table>
</itemTemplate>
<EditItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Name: <asp:TextBox id="txtname" Runat="server" Columns="20"
Text='<%# DataBinder.Eval(Container.DataItem, "name") %>' /></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td>ID: <asp:label id="lblCommentid" runat="server"
text='<%# DataBinder.Eval(Container.DataItem, "commentID") %>' /></td>
<td>Approved: <asp:TextBox id="txtapprove"
Runat="server" Columns="2" Text='<%# DataBinder.Eval(Container.DataItem,
"approved") %>' />1 = Y / 0 = N</td>
</tr>
</table></td>
<td>Date: <asp:TextBox id="txtdate" Runat="server"
Columns="30" Text='<%# DataBinder.Eval(Container.DataItem, "date") %>' /></td>
</tr>
<tr>
<td>City: <asp:TextBox id="txtcity" Runat="server"
Columns="30" Text='<%# DataBinder.Eval(Container.DataItem, "city") %>' /></td>
<td>Country: <asp:TextBox id="txtcountry" Runat="server"
Columns="30" Text='<%# DataBinder.Eval(Container.DataItem, "country") %>'
/></td>
</tr>
<tr>
<td>Email: <asp:TextBox id="txtemail" Runat="server"
Columns="30" Text='<%# DataBinder.Eval(Container.DataItem, "email") %>' /></td>
<td>URL: <asp:TextBox id="txturl" Runat="server" Columns="30"
Text='<%# DataBinder.Eval(Container.DataItem, "url") %>' /></td>
</tr>
</table></td>
</tr>
<tr>
<td>Comments: <asp:TextBox textmode="multiline" id="txtcomment"
Runat="server" Columns="30" Rows="4" Text='<%#
DataBinder.Eval(Container.DataItem, "comment") %>' /></td>
</tr>
<tr>
<td align="center">
<asp:Button id="btnUpdate" Runat="server" CommandName="update"
Text="Update" /><asp:Button id="btnCancel" Runat="server" CommandName="cancel"
Text="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:DataList>
<br />
<table width="560" border="0" cellspacing="0" cellpadding="0"
align="center"
style="filter:progid:DXImageTransform.Microsoft.Gr adient(GradientType=1, StartColorStr='#FF99CCFF', EndColorStr='#FFFFCC00');
padding-left: 5px;">
<tr>
<td>
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="default.aspx" class="comment">View Comments</asp:HyperLink>
</td>
</tr>
</table>
</form>
</body>
</html>
</code>
Here's the .
vb file
<code>
Imports System
Imports System.Data
Imports System.Data.Oledb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Public Class Approve : Inherits Page
Private strConn As String =
ConfigurationSettings.AppSettings("myDSN")
Public dtlComments As DataList
Public Sub Page_Load(sender as Object, e as EventArgs)
If Not IsPostBack Then
BindTheData()
End If
End Sub
Private Sub BindTheData()
Dim objConn as new OledbConnection(strConn)
Dim strSQL as String
strSQL = "SELECT * FROM Comments WHERE Approved='0'"
Dim sda as new OledbDataAdapter(strSQL, objConn)
Dim ds as new DataSet()
sda.Fill(ds,"Comments")
dtlComments.DataSource = ds.Tables("Comments").DefaultView
dtlComments.DataBind()
End Sub
Public Sub dtlComments_Edit(sender as Object, e as
DataListCommandEventArgs)
dtlComments.EditItemIndex = e.Item.ItemIndex
BindTheData()
End Sub
Public Sub dtlComments_Cancel(sender as Object, e as
DataListCommandEventArgs)
dtlComments.EditItemIndex = -1
BindTheData()
End Sub
Public Sub dtlComments_Update(sender As Object, e As
DataListCommandEventArgs)
Dim strName, strApprove, strDate, strCity As String
Dim strCountry, strEmail, strURL, strComment, strCommentID As
String
strName = CType(e.Item.FindControl("txtName"), TextBox).Text
strApprove = CType(e.Item.FindControl("txtApprove"), TextBox).Text
strDate = CType(e.Item.FindControl("txtdate"), TextBox).Text
strCity = CType(e.Item.FindControl("txtcity"), TextBox).Text
strCountry = CType(e.Item.FindControl("txtcountry"),TextBox).Te xt
strEmail = CType(e.Item.FindControl("txtemail"), TextBox).Text
strURL = CType(e.Item.FindControl("txturl"),TextBox).Text
strComment = CType(e.Item.FindControl("txtcomment"),TextBox).Te xt
strCommentID = CType(e.Item.FindControl("lblCommentID"),
Label).Text
Dim strSQL As String
strSQL = "Update Comments " & _
"Set [Name] = @Name," & _
"[eMail] = @Email," & _
"[URL] = @URL, " & _
"[City] = @City, " & _
"[Country] = @Country, " & _
"[Date] = @Date, " & _
"[Comment] = @Comment, " & _
"[Approved] = @Approved, " & _
"WHERE CommentID = @CommentID"
Dim objConn As New OledbConnection(strConn)
Dim Cmd As New OledbCommand(strSQL, objConn)
With Cmd.Parameters
.Add(New OleDbParameter("@Name", strName))
.Add(New OleDbParameter("@Email", strEmail))
.Add(New OleDbParameter("@Url", strURL))
.Add(New OleDbParameter("@City", strCity))
.Add(New OleDbParameter("@Country", strCountry))
.Add(New OleDbParameter("@Date", strDate))
.Add(New OleDbParameter("@Comment", strComment))
.Add(New OleDbParameter("@Approved", strApprove))
.Add(New OledbParameter("@CommentID", strCommentID))
End With
objConn.Open()
cmd.ExecuteNonQuery()
objConn.Close()
dtlComments.EditItemIndex = -1
BindTheData()
End Sub
End Class
</code>
Thank you so much for your help.