Using update command for Typed DataSets dataadapter

Posted on 2006-04-11
Last Modified: 2011-09-20
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)

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

        With qdr
            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

        End With

    End Sub
Question by:rodmjay
    1 Comment
    LVL 96

    Accepted Solution


    1) You are filling dsQuestions.QuestionsDataTable and not the DataSet, so why have a DataSet.
    2) To add rows, follow these steps:

       a) Create a new row
       b) Set the values
       c) Add the row to the DataTable.

         qdr = qdt.NewQuestionsRow()
         qdr.QuestionText = txtQuestion.Text
         qdr.QuestionType = 1
         qdr.Answer1 = TextBox1.Text
         qdr.Answer2 = TextBox2.Text
         qdr.Answer3 = TextBox3.Text
         qdr.Answer4 = TextBox4.Text
         qdr.Answer5 = TextBox5.Text


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now