Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. updating database using dataset

updating database using dataset

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasearchitectureperformanceannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mayhem_rules
    wrote on last edited by
    #1

    Hey guys, This is some information which I have been reading on many websites regarding datasets. A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch. Please refer to the words that I have marked as bold. Can anyone tell me how that is done. I am a fresher in .NET. I really think that the execution speed of my application suffers since I update each record individually. I want to know how I can add/modify/delete to a dataset and then update the changes to the database. With Best Regards, Mayur

    R D 2 Replies Last reply
    0
    • M mayhem_rules

      Hey guys, This is some information which I have been reading on many websites regarding datasets. A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch. Please refer to the words that I have marked as bold. Can anyone tell me how that is done. I am a fresher in .NET. I really think that the execution speed of my application suffers since I update each record individually. I want to know how I can add/modify/delete to a dataset and then update the changes to the database. With Best Regards, Mayur

      R Offline
      R Offline
      RichardBerry
      wrote on last edited by
      #2

      Here are two funtions for Access. Private Sub Do_Some_Work() Dim dt as DataTable FillTable(dt,"SELECT * FROM TableName") ' 'Modify the table ' UpdateTable(dt,"SELECT * FROM TableName") End Sub Public Function FillTable(ByRef dt As DataTable, ByVal SelectString As String) As Boolean Dim path As String = Application.StartupPath Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & " Data source= " & path & "\MyDB.mdb" Dim strSelect As String = SelectString '& ";Connect Timeout=10" Dim cn As New OleDb.OleDbConnection(cnStr) Dim cmd As New OleDb.OleDbCommand(strSelect, cn) Dim da As New OleDb.OleDbDataAdapter(cmd) cmd.CommandTimeout = 5 Try da.FillSchema(dt, SchemaType.Source) da.Fill(dt) Return True Catch ex As Exception Messagebox.Show(ex.Message) Return False Finally cn.Close() End Try End Function Public Function UpdateTable(ByVal dt As DataTable, ByVal strSelect As String) As Boolean Dim path As String = Application.StartupPath Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & " Data source= " & path & "\MyDB.mdb" '& ";Connect Timeout=10" Dim cn As New OleDb.OleDbConnection(cnStr) Dim cmd As New OleDb.OleDbCommand(strSelect, cn) Dim da As New OleDb.OleDbDataAdapter(cmd) Dim cb As New OleDb.OleDbCommandBuilder(da) cmd.CommandTimeout = 5 Try cb.GetUpdateCommand() da.Update(dt) Return True Catch ex As Exception Messagebox.Show(ex.Message) Return False Finally cn.Close() End Try End Function

      1 Reply Last reply
      0
      • M mayhem_rules

        Hey guys, This is some information which I have been reading on many websites regarding datasets. A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch. Please refer to the words that I have marked as bold. Can anyone tell me how that is done. I am a fresher in .NET. I really think that the execution speed of my application suffers since I update each record individually. I want to know how I can add/modify/delete to a dataset and then update the changes to the database. With Best Regards, Mayur

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        When you use a DataSet, or DataTable, with a DataAdapter object, you supply the DataAdapter with the SELECT statement to fill the DataSet. Your user makes any required changes to the data, then tells your app to update the database. This is where I think you're duplicating the functionality of the DataAdapter. The DataAdapter also needs the appropriate SQL commands for UPDATE, INSERT, and DELETE operations on the data it retrieved using the SELECT command. When the dirty data is written back to the database, the DataAdapter looks at each recond in the DataSet/DataTable and, using a flag attached to each record, decides which of those SQL commands to execute for that record, if any. You may be doing the same thing, or something similar. But, in any case, you're probably duplicating the functionality of the DataAdapter. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups