Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 437189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:33:11+00:00 2026-05-12T20:33:11+00:00

Why my set of codes didn’t update in DataSet? Then it goes to Error.

  • 0

Why my set of codes didn’t update in DataSet? Then it goes to Error. Please anyone check this code and point me out where I am missing. Thanks in advance!

Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click

    Dim conxMain As New SqlConnection("Data Source=SERVER;Initial Catalog=DBTest;Persist Security Info=True;User ID=username;Password=pwds")

    Dim dadPurchaseInfo As New SqlDataAdapter
    Dim dsPurchaseInfo As New DataSet1
    Try
        Dim dRow As DataRow

        conxMain.Open()

        Dim cmdSelectCommand As SqlCommand = New SqlCommand("SELECT * FROM Stock", conxMain)
        cmdSelectCommand.CommandTimeout = 30

        dadPurchaseInfo.SelectCommand = cmdSelectCommand
        Dim builder As SqlCommandBuilder = New SqlCommandBuilder(dadPurchaseInfo)

        dadPurchaseInfo.Fill(dsPurchaseInfo, "Stock")


        For Each dRow In dsPurchaseInfo.Tables("Stock").Rows
            If CInt(dRow.Item("StockID").ToString()) = 2 Then
                dRow.Item("StockCode") = "Re-Fashion[G]"
            End If

        Next
        dadPurchaseInfo.Update(dsPurchaseInfo, "Stock")

    Catch ex As Exception
        MsgBox("Error : ")
    Finally
        If dadPurchaseInfo IsNot Nothing Then
            dadPurchaseInfo.Dispose()
        End If

        If dsPurchaseInfo IsNot Nothing Then
            dsPurchaseInfo.Dispose()
        End If

        If conxMain IsNot Nothing Then
            conxMain.Close()
            conxMain.Dispose()
        End If
    End Try
End Sub
  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:33:12+00:00Added an answer on May 12, 2026 at 8:33 pm

    Does your condition in the loop get executed (set a break point!)? Where is the error thrown? What error?

    Also, why does it use ToString at all? This seems redundant.

    If CInt(dRow.Item("StockID")) = 2 Then
    

    Should be enough.

    Finally, you’re performing redundant cleanup:

    If conxMain IsNot Nothing Then
        conxMain.Close()
        conxMain.Dispose()
    End If
    

    Dispose implies Close – no need to perform both operations:

    Close and Dispose are functionally equivalent.

    [Source: MSDN]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare a defined code against a set of blocked country codes.
I have a set of code as per below. The point is to have
I have this set of code which was working fine about an hour or
How i can port this set of code in wp7 -(NSString *) timeSincePosted:(NSString *)ad_date
I find myself writing code that looks like this a lot: set<int> affected_items; while
Please compare these two codes. I can't understand why former one didn't work while
I’m confused about this; instead of writing tweepy codes like- auth=tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret)
I currently have my code set to disable the submit button when the field
I have the following code set up in my Startup IDictionary<string, string> properties =
Why does the following ARM code set R0 to 0 after the SWI ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.