next record in dataset is not changing...pls help

J

jaYPee

i have created an sqldataadapter using a wizard and added the
necessary textboxes in my form and done some navigational button like
previous and next button to browse the record. now i made some changes
to my record in my textboxes to find out if the record is save to the
database. i can save the first record of the dataset but when i click
the next button to browse to another record and make some changes and
save by clicking the btnsave button the record is not updated to the
database. here is the btnsave event.

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnSave.Click
Try
Dim cbStudents As New
SqlCommandBuilder(SqlDataAdapter1)

cmStudents.EndCurrentEdit()

SqlDataAdapter1.Update(DsStudentCourse1)
SqlDataAdapter2.Update(DsStudentCourse1)
SqlDataAdapter3.Update(DsStudentCourse1)

DsStudentCourse1.Clear()
SqlDataAdapter1.Fill(DsStudentCourse1)
SqlDataAdapter2.Fill(DsStudentCourse1)
SqlDataAdapter3.Fill(DsStudentCourse1)
SqlDataAdapter4.Fill(DsStudentCourse1)
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

and here is the commandtext of the updatecommand in my
sqldataadapter1.

UPDATE Students
SET LastName = @LastName, FirstName = @FirstName,
MiddleName = @MiddleName, Gender = @Gender, Address = @Address,
ParentGuardian = @ParentGuardian, ProgramID =
@ProgramID, DateofBirth = @DateofBirth, PlaceofBirth = @PlaceofBirth,
Scholarship = @Scholarship, ElemSchool =
@ElemSchool, ESAddress = @ESAddress, ESSchYear = @ESSchYear, SecSchool
= @SecSchool,
SSAddress = @SSAddress, SSSchYear = @SSSchYear
WHERE (IDNo = @Original_IDNo) AND (Address = @Original_Address OR
@Original_Address IS NULL AND Address IS NULL)
AND (DateofBirth = @Original_DateofBirth OR
@Original_DateofBirth IS NULL AND DateofBirth IS
NULL) AND (ESAddress = @Original_ESAddress OR
@Original_ESAddress IS NULL AND ESAddress IS
NULL) AND (ESSchYear = @Original_ESSchYear OR
@Original_ESSchYear IS NULL AND ESSchYear IS
NULL) AND (ElemSchool = @Original_ElemSchool OR
@Original_ElemSchool IS NULL AND ElemSchool IS
NULL) AND (FirstName = @Original_FirstName OR
@Original_FirstName IS NULL AND FirstName IS
NULL) AND (Gender = @Original_Gender OR
@Original_Gender IS NULL AND Gender IS NULL) AND
(LastName = @Original_LastName OR
@Original_LastName IS NULL AND LastName IS NULL)
AND (MiddleName = @Original_MiddleName OR
@Original_MiddleName IS NULL AND MiddleName IS
NULL) AND (ParentGuardian = @Original_ParentGuardian OR
@Original_ParentGuardian IS NULL AND
ParentGuardian IS NULL) AND (PlaceofBirth = @Original_PlaceofBirth OR
@Original_PlaceofBirth IS NULL AND PlaceofBirth
IS NULL) AND (ProgramID = @Original_ProgramID OR
@Original_ProgramID IS NULL AND ProgramID IS
NULL) AND (SSAddress = @Original_SSAddress OR
@Original_SSAddress IS NULL AND SSAddress IS
NULL) AND (SSSchYear = @Original_SSSchYear OR
@Original_SSSchYear IS NULL AND SSSchYear IS
NULL) AND (Scholarship = @Original_Scholarship OR
@Original_Scholarship IS NULL AND Scholarship IS
NULL) AND (SecSchool = @Original_SecSchool OR
@Original_SecSchool IS NULL AND SecSchool IS
NULL);
SELECT IDNo, LastName, FirstName,
MiddleName, Gender, Address, ParentGuardian, ProgramID, DateofBirth,
PlaceofBirth, Scholarship,
ElemSchool,
ESAddress, ESSchYear, SecSchool, SSAddress, SSSchYear
FROM Students
WHERE (IDNo = @IDNo)

thanks in advance for any help.
 
W

William Ryan eMVP

jaYPee:

How are you navigating?
jaYPee said:
i have created an sqldataadapter using a wizard and added the
necessary textboxes in my form and done some navigational button like
previous and next button to browse the record. now i made some changes
to my record in my textboxes to find out if the record is save to the
database. i can save the first record of the dataset but when i click
the next button to browse to another record and make some changes and
save by clicking the btnsave button the record is not updated to the
database. here is the btnsave event.

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnSave.Click
Try
Dim cbStudents As New
SqlCommandBuilder(SqlDataAdapter1)

cmStudents.EndCurrentEdit()

SqlDataAdapter1.Update(DsStudentCourse1)
SqlDataAdapter2.Update(DsStudentCourse1)
SqlDataAdapter3.Update(DsStudentCourse1)

DsStudentCourse1.Clear()
SqlDataAdapter1.Fill(DsStudentCourse1)
SqlDataAdapter2.Fill(DsStudentCourse1)
SqlDataAdapter3.Fill(DsStudentCourse1)
SqlDataAdapter4.Fill(DsStudentCourse1)
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

and here is the commandtext of the updatecommand in my
sqldataadapter1.

UPDATE Students
SET LastName = @LastName, FirstName = @FirstName,
MiddleName = @MiddleName, Gender = @Gender, Address = @Address,
ParentGuardian = @ParentGuardian, ProgramID =
@ProgramID, DateofBirth = @DateofBirth, PlaceofBirth = @PlaceofBirth,
Scholarship = @Scholarship, ElemSchool =
@ElemSchool, ESAddress = @ESAddress, ESSchYear = @ESSchYear, SecSchool
= @SecSchool,
SSAddress = @SSAddress, SSSchYear = @SSSchYear
WHERE (IDNo = @Original_IDNo) AND (Address = @Original_Address OR
@Original_Address IS NULL AND Address IS NULL)
AND (DateofBirth = @Original_DateofBirth OR
@Original_DateofBirth IS NULL AND DateofBirth IS
NULL) AND (ESAddress = @Original_ESAddress OR
@Original_ESAddress IS NULL AND ESAddress IS
NULL) AND (ESSchYear = @Original_ESSchYear OR
@Original_ESSchYear IS NULL AND ESSchYear IS
NULL) AND (ElemSchool = @Original_ElemSchool OR
@Original_ElemSchool IS NULL AND ElemSchool IS
NULL) AND (FirstName = @Original_FirstName OR
@Original_FirstName IS NULL AND FirstName IS
NULL) AND (Gender = @Original_Gender OR
@Original_Gender IS NULL AND Gender IS NULL) AND
(LastName = @Original_LastName OR
@Original_LastName IS NULL AND LastName IS NULL)
AND (MiddleName = @Original_MiddleName OR
@Original_MiddleName IS NULL AND MiddleName IS
NULL) AND (ParentGuardian = @Original_ParentGuardian OR
@Original_ParentGuardian IS NULL AND
ParentGuardian IS NULL) AND (PlaceofBirth = @Original_PlaceofBirth OR
@Original_PlaceofBirth IS NULL AND PlaceofBirth
IS NULL) AND (ProgramID = @Original_ProgramID OR
@Original_ProgramID IS NULL AND ProgramID IS
NULL) AND (SSAddress = @Original_SSAddress OR
@Original_SSAddress IS NULL AND SSAddress IS
NULL) AND (SSSchYear = @Original_SSSchYear OR
@Original_SSSchYear IS NULL AND SSSchYear IS
NULL) AND (Scholarship = @Original_Scholarship OR
@Original_Scholarship IS NULL AND Scholarship IS
NULL) AND (SecSchool = @Original_SecSchool OR
@Original_SecSchool IS NULL AND SecSchool IS
NULL);
SELECT IDNo, LastName, FirstName,
MiddleName, Gender, Address, ParentGuardian, ProgramID, DateofBirth,
PlaceofBirth, Scholarship,
ElemSchool,
ESAddress, ESSchYear, SecSchool, SSAddress, SSSchYear
FROM Students
WHERE (IDNo = @IDNo)

thanks in advance for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top