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

  • SEARCH
  • Home
  • 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 7410523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:14:47+00:00 2026-05-29T06:14:47+00:00

i’m getting confuse about dataset and dataview, which i either use dataset to update

  • 0

i’m getting confuse about dataset and dataview, which i either use dataset to update data or dataview to filter data, but cannot have both together at the same time.

Private Sub searchStaff_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ds = New DataSet

        dv = New DataView

        Dim ad As New SqlDataAdapter("SELECT * FROM staff", connection)

        ad.Fill(ds, "staff")

        dv.Table = ds.Tables("staff")

        Me.DataGridView1.DataSource = dv
End Sub

Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged

         Try
                dv.RowFilter = "StaffName like '" & txtSearch.Text & "*'"

          Catch ex As Exception
        End Try
      End Sub

this is the code of filtering data on dataview,which work fine for me.
but later on, i have to implement another function of update data on datagridview, what i found on internet require me to use dataset as datasource rather than dataview.

Private Sub searchStaff_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        connection = New SqlConnection(connectionString)
        ds = New DataSet
        cmd = New SqlCommand("SELECT * FROM staff", connection)
        adp=New SqlDataAdapter(cmd)
        adp.Fill(ds, "staff")
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataMember = "staff"

    End Sub
Private Sub btnUpdate_ClickEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.ClickEvent
    Dim cmdbuilder As New SqlCommandBuilder(adp)
    Dim i As Integer

    Try
        i = adp.Update(ds, "staff")
        MsgBox("Record updated= " & i)

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

so i hope some 1 can show me, how to i can have both functions”update,filter” at the same time by using what datasource?

  • 1 1 Answer
  • 0 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-29T06:14:47+00:00Added an answer on May 29, 2026 at 6:14 am

    You must use DataSet (or DataTable) with SqlDataAdapter for make an Update operation; DataView is used for filter data but not to commit changes to database. Here an example for your searchStaff_Load method:

    Private Sub searchStaff_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         
    
        connection = New SqlConnection(connectionString)    
        ds = New DataSet         
        cmd = New SqlCommand("SELECT * FROM staff", connection)    
        adp=New SqlDataAdapter(cmd)        
        adp.Fill(ds, "staff")
        Me.DataGridView1.DataSource = ds.Tables("staff").DefaultView 'Assign DataView to grid
        'Me.DataGridView1.DataMember = "staff"      'No need when using DataView
    
    End Sub 
    

    The txtSearch_TextChanged and btnUpdate_ClickEvent are already correct. The first filter using DataView, the second update database using DataSet.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small

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.