Link to home
Start Free TrialLog in
Avatar of rodmjay
rodmjayFlag for United States of America

asked on

Using update command for Typed DataSets dataadapter

I am trying to do an update to the database based on my typed dataset, here is the code i have and it doesnt seem to be inserting anything.  


    Dim qds As New dsQuestions
    Dim qda As New dsQuestionsTableAdapters.QuestionsTableAdapter
    Dim qdt As New dsQuestions.QuestionsDataTable
    Dim qdr As dsQuestions.QuestionsRow

    Protected Sub btnAddAnother_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        qda.Fill(qdt)
        qdr = CType(qdt.NewRow, dsQuestions.QuestionsRow)

        With qdr
            .BeginEdit()
            Select Case ddlQuestionType.SelectedValue.ToLower
                Case "test"
                    .TestID = CInt(Request.QueryString("id"))
                Case "workbook"
                    .WorkbookID = CInt(Request.QueryString("id"))
            End Select
            .QuestionText = txtQuestion.Text
            .QuestionType = 1
            .Answer1 = TextBox1.Text
            .Answer2 = TextBox2.Text
            .Answer3 = TextBox3.Text
            .Answer4 = TextBox4.Text
            .Answer5 = TextBox5.Text
            If .HasErrors Then
                Throw New Exception("there are errors")
            End If
            .EndEdit()

        End With
        qdt.ImportRow(qdr)
        qda.Update(qdt)

    End Sub
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial