Basically i am trying to update a specific row in the datagrid of my Students table. But as soon as i run the query (displayed below), all of the rows in the datagrid gets updated instead of just 1 row.
i am using the updatequery in microsoft access. i made a select query which select the table information that i wopuld like to edit called getStudents and put this in the update query.
Here is the sql view of my update query:
I have been trying to get it working for days but to no avail, any help would be greatly appreciated.
Code:
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
Dim conn As OleDbConnection = New OleDbConnection
conn.ConnectionString = strConn
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand
cmd.CommandText = "qyUpdateStudents"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = conn
cmd.Parameters.AddWithValue("@Reference", txtRef2.Text)
cmd.Parameters.AddWithValue("@FName", txtfname2.Text)
cmd.Parameters.AddWithValue("@LName", txtlname2.Text)
cmd.Parameters.AddWithValue("@Address", txtaddress2.Text)
cmd.Parameters.AddWithValue("@PostCode", txtpostcode2.Text)
cmd.Parameters.AddWithValue("@County", txtcounty2.Text)
cmd.Parameters.AddWithValue("@Tel", txttel2.Text)
cmd.Parameters.AddWithValue("@Mobile", txtmobile2.Text)
cmd.Parameters.AddWithValue("@CourseType", txtcoursetype2.Text)
cmd.Parameters.AddWithValue("@CourseTitle", txtcoursetitle2.Text)
cmd.Parameters.AddWithValue("@Duration", txtduration2.Text)
cmd.Parameters.AddWithValue("@YearofStudy", txtyearofstudy2.Text)
cmd.Parameters.AddWithValue("@Fees", txtfees2.Text)
Dim incompleted As Integer = cmd.ExecuteNonQuery
If incompleted > -1 Then
MessageBox.Show("The Student Details have been Updated Successfully", "Saving.....", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Error Updating Data.....Please Try Again", "Error....", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
End If
conn.Close()
conn.Dispose()
cmd.Dispose()
End Sub
i am using the updatequery in microsoft access. i made a select query which select the table information that i wopuld like to edit called getStudents and put this in the update query.
Here is the sql view of my update query:
Code:
PARAMETERS Reference Long, FName Text ( 255 ), LName Text ( 255 ), Address Text ( 255 ), PostCode Text ( 255 ), County Text ( 255 ), Tel Text ( 255 ), Mobile Text ( 255 ), CourseType Text ( 255 ), CourseTitle Text ( 255 ), Duration Short, YearofStudy Short, Fees Currency;
UPDATE qyGetStudents SET qyGetStudents.Reference = [Reference], qyGetStudents.FName = [FName], qyGetStudents.LName = [LName], qyGetStudents.Address = [Address], qyGetStudents.PostCode = [PostCode], qyGetStudents.County = [County], qyGetStudents.Tel = [Tel], qyGetStudents.Mobile = [Mobile], qyGetStudents.CourseType = [CourseType], qyGetStudents.CourseTitle = [CourseTitle], qyGetStudents.Duration = [Duration], qyGetStudents.YearofStudy = [YearofStudy], qyGetStudents.Fees = [Fees];
I have been trying to get it working for days but to no avail, any help would be greatly appreciated.