I'm having trouble with an SQL statement that I am using in VB.net . I'm trying to update a Datagrid and database
(Handles dgvStu.CellValueChanged) with new variables that the user has input, But I am getting an error
"Query input must contain atleast one table or query"
Here is my SQL statement:
"INSERT INTO tblStudent (LegalForename, LegalSurname, DoB, Gender) VALUES ('" & LegalFname & "' , '" & LegalSname & "', '" & DoB & "', '" & Gender & "' ) WHERE (((tblStudent.StudentID)= '" & StuID & "' ));"
Here is the entire Subroutine in VB.NET if it's needed:
Private Sub CheckCellChange() Handles dgvStu.CellValueChanged
Dim StuID As String = dgvStu.CurrentRow.Cells(0).Value
Dim LegalFname As String = dgvStu.CurrentRow.Cells(1).Value
Dim LegalSname As String = dgvStu.CurrentRow.Cells(2).Value
Dim Gender As String = dgvStu.CurrentRow.Cells(3).Value
Dim DoB As String = dgvStu.CurrentRow.Cells(4).Value
Dim mysql = "INSERT INTO tblStudent (LegalForename, LegalSurname, DoB, Gender) VALUES ('" & LegalFname & "' , '" & LegalSname & "', '" & DoB & "', '" & Gender & "' ) WHERE (((tblStudent.StudentID)= '" & StuID & "' ));"
Try
If LegalFname <> "" Then
If LegalSname <> "" Then
If Gender <> "" Then
If DoB <> "" Then
End If
End If
End If
End If
UpdateDB(mysql)
Catch ex As Exception
MsgBox("Something Went Wrong!")
End Try
End Sub
From my point of view I can see no syntax errors, but a second opinion will be helpful.
I've tried playing around with the syntax to no avail,but the Access Error is fairly ambiguous so I don't really know what's going on.
Thanks
Ataxia .

New Topic/Question
Reply



MultiQuote






|