Click here to Skip to main content
15,911,030 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: urgent Pin
Sathesh Sakthivel15-May-07 21:14
Sathesh Sakthivel15-May-07 21:14 
AnswerRe: urgent Pin
meeram39515-May-07 22:49
meeram39515-May-07 22:49 
AnswerFOUR urgent posts in one day Pin
leckey16-May-07 3:25
leckey16-May-07 3:25 
Questionproblem in creating active x in .net Pin
nikhilrawat2315-May-07 20:56
nikhilrawat2315-May-07 20:56 
Questionhow we create tree view? Pin
deepaksringr15-May-07 20:56
deepaksringr15-May-07 20:56 
AnswerRe: how we create tree view? Pin
Sathesh Sakthivel15-May-07 21:18
Sathesh Sakthivel15-May-07 21:18 
QuestionModal Dialog and Session Problem Pin
RaviJJain15-May-07 20:53
RaviJJain15-May-07 20:53 
QuestionASP.NET with VB in Connecting Database Pin
JosephWONG15-May-07 20:50
JosephWONG15-May-07 20:50 
Dear all,

While I try to compile the follwing code, I found a error message occurred. Can anyone help me to solve the problem??

Thanks!

Error Message:
System.Data.OleDb.OleDbException: UPDATE syntex error

Code As below:
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<%@ Page Language="VB" AutoEventWireup="True"%>








<title>Welcome to School Adaptable Management System










Today:
16-04-07





Edit Announcement




<asp:datagrid id="dgEditAnnounce" runat="server" cssclass="Normal" cellpadding="2"
="" gridlines="Horizontal" autogeneratecolumns="False" oneditcommand="EditCmd" oncancelcommand="CancelCmd" onupdatecommand="UpdateCmd">

<columns>
<asp:editcommandcolumn buttontype="LinkButton"
="" updatetext="Save" canceltext="Cancel" edittext="Edit" headertext="Edit">

<asp:boundcolumn datafield="Help_ID" headertext="ID" readonly="True">


<asp:boundcolumn datafield="Help_Type" headertext="Type">


<asp:boundcolumn datafield="Help_Desc" headertext="Content">


<asp:boundcolumn datafield="Help_Reply" headertext="Reply">


<asp:boundcolumn datafield="Help_Date" headertext="Date</br>(YYYY/MM/DD)">


<asp:boundcolumn datafield="Help_Del" headertext="Status</br>(0=Post/ 1=Not Post)">











Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)

If Not Page.IsPostBack Then
Me.BindGrid()
End If

End Sub

Private Sub BindGrid()
Dim tbAnnounce As New DataTable
Dim strConnection As String ="provider=Microsoft.Jet.OLEDB.4.0; data source=C:\Inetpub\wwwroot\SAMS2\quiz.mdb"
Dim objConnection As New OleDbConnection(strConnection)
Dim strSQL As String="Select * From tb_Help'"
Dim dtAnnouce As New OleDbDataAdapter(strSQL, objConnection)

dtAnnouce.Fill(tbAnnounce)
dgEditAnnounce.DataSource=tbAnnounce
dgEditAnnounce.DataBind()

End Sub

Private Sub EditCmd (ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
dgEditAnnounce.EditItemIndex = e.Item.ItemIndex
Me.BindGrid()
End Sub

Private Sub UpdateCmd (ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
Dim sbSQL As New System.Text.StringBuilder

sbSQL.Append("UPDATE tb_Help SET ")
sbSQL.Append("Help_Type = @Help_Type, ")
sbSQL.Append("Help_Desc = @Help_Desc, ")
sbSQL.Append("Help_Reply= @Help_Reply, ")
sbSQL.Append("Help_Date = @Help_Date, ")
sbSQL.Append("Help_Del = @Help_Del, ")
sbSQL.Append("WHERE Help_ID = @Help_ID")

Dim iHelp_ID As Int32 = Convert.ToInt32(e.Item.Cells(1).Text)
Dim sHelp_Type As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim sHelp_Desc As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim sHelp_Reply As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim sHelp_Date As String = CType(e.Item.Cells(5).Controls(0),TextBox).Text
Dim sHelp_Del As String = CType(e.Item.Cells(6).Controls(0),TextBox).Text

Dim strConnection As String ="provider=Microsoft.Jet.OLEDB.4.0; data source=C:\Inetpub\wwwroot\SAMS2\quiz.mdb"
Dim con As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand(sbSQL.ToString(), con)

With cmd.Parameters
.Add("@Help_Type", sHelp_Type)
.Add("@Help_Desc", sHelp_Desc)
.Add("@Help_Reply", sHelp_Reply)
.Add("@Help_Date", sHelp_Date)
.Add("@Help_Del", sHelp_Del)
End With

Try
con.Open()
If cmd.ExecuteNonQuery() < 1 Then
Throw New System.Exception("The record was not update")
End If
Finally
If Not con Is Nothing AndAlso con.State = ConnectionState.Open Then
con.Close()
End If
End Try

dgEditAnnounce.EditItemIndex = -1
Me.BindGrid()
End Sub

Private Sub CancelCmd (ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
dgEditAnnounce.EditItemIndex = -1
Me.BindGrid()
End Sub



Finally, I hope my message can assist or takle your problem.
God Bless You!

AnswerRe: ASP.NET with VB in Connecting Database Pin
Sathesh Sakthivel15-May-07 21:08
Sathesh Sakthivel15-May-07 21:08 
GeneralRe: ASP.NET with VB in Connecting Database Pin
JosephWONG15-May-07 21:51
JosephWONG15-May-07 21:51 
QuestionFreezing Header of GridView Pin
248912815-May-07 20:48
248912815-May-07 20:48 
QuestionUrgent Pin
jamesmani2k515-May-07 20:47
jamesmani2k515-May-07 20:47 
AnswerRe: Urgent Pin
Sathesh Sakthivel15-May-07 21:06
Sathesh Sakthivel15-May-07 21:06 
AnswerRe: Urgent Pin
Guffa15-May-07 22:05
Guffa15-May-07 22:05 
Questionvery urgent Pin
deepaksringr15-May-07 20:13
deepaksringr15-May-07 20:13 
AnswerRe: very urgent Pin
Pranav2315-May-07 20:19
Pranav2315-May-07 20:19 
GeneralRe: very urgent Pin
deepaksringr15-May-07 20:21
deepaksringr15-May-07 20:21 
AnswerRe: very urgent Pin
248912815-May-07 20:28
248912815-May-07 20:28 
GeneralRe: very urgent Pin
deepaksringr15-May-07 21:00
deepaksringr15-May-07 21:00 
AnswerRe: very urgent Pin
N a v a n e e t h15-May-07 21:31
N a v a n e e t h15-May-07 21:31 
Questionurgent Pin
deepaksringr15-May-07 20:10
deepaksringr15-May-07 20:10 
AnswerRe: urgent Pin
Sathesh Sakthivel15-May-07 20:12
Sathesh Sakthivel15-May-07 20:12 
GeneralRe: urgent Pin
deepaksringr15-May-07 20:22
deepaksringr15-May-07 20:22 
AnswerRe: urgent Pin
248912815-May-07 20:21
248912815-May-07 20:21 
GeneralRe: urgent Pin
Sathesh Sakthivel15-May-07 20:23
Sathesh Sakthivel15-May-07 20:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.