This is about a question/answer utility forum being built in VB.NET. The questions are getting saved in the access database, for the same question user has to pick a yes or no check button and then answer in a text box. This does not work. Error says
Error in Update syntax
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\myforum.accdb;"
Dim Con As OleDbConnection = New OleDbConnection(constr)
Con.Open()
Dim com As OleDbCommand = New OleDbCommand
com.Connection = Con
Try
Dim CheckedRows =
(
From Rows In DataGridView1.Rows.Cast(Of DataGridViewRow)()
Where CBool(Rows.Cells("Answer").Value) = True
).ToList
If CheckedRows.Count = 0 Then
MessageBox.Show("Nothing checked")
Else
com = New OleDbCommand("UPDATE fquestions set reply VALUES('" & TextBox3.Text & "')", Con)
Dim Num As Integer = com.ExecuteNonQuery
If (Num <> 0) Then
MessageBox.Show("Replied the question....", "Add Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
Else
MessageBox.Show("Record is not Added....", "Add Record Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
Con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Aucun commentaire:
Enregistrer un commentaire