Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2005 Update records

$
0
0
Hi!

I have this code to insert records
Code:

            'insert all selected subjects
            y = Me.BindingContext(dsSub.Tables("tblSubjects")).Count - 1
            Me.BindingContext(dsSub.Tables("tblSubjects")).Position = 0

            For x = 0 To y
                cmdStudList.CommandText = "INSERT INTO tblregister(IDNo,SubjectName, " & _
                        "FirstName,MI,LastName,YearLevel, Address,Gender) " & _
                    "VALUES ('" & txtStudID.Text & "','" & txtSubjectName.Text & _
                    "','" & txtFirstName.Text & "', '" & txtMI.Text & _
                    "','" & txtLastName.Text & "','" & cboYearLevel.Text & _
                    "','" & SQLEncode(txtCompleteAddress.Text) & "','" & txtGender.Text & "')"
                daStud.InsertCommand = cmdStudList
                daStud.InsertCommand.ExecuteNonQuery()
                Me.BindingContext(dsSub.Tables("tblSubjects")).Position += 1
                'Debug.Print("INSERT INTO tblregister(IDNo, SubjectId) VALUES ('" & txtIDNo.Text & "', '" & txtSubjectID.Text & "')")
                daStud.InsertCommand = cmdStudList
            Next

I want to update ONLY the subjects assigned to a certain students. can you help me convert the code above into Update query?

Thanks.

Viewing all articles
Browse latest Browse all 27329

Trending Articles