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. update data?

update data?

Scheduled Pinned Locked Moved Visual Basic
performancequestionannouncement
4 Posts 4 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.
  • C Offline
    C Offline
    cotdot11111
    wrote on last edited by
    #1

    i have 2 following solution the first

    sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
    SqlCommand1.ExecuteNonQuery()

    the second

    'fill into datagridview
    SqlCommand1.CommandText = "select * from customers "
    SqlDataAdapter1.SelectCommand = SqlCommand1
    SqlDataAdapter1.Fill(DataSet1, "customers")
    DataGridView1.DataSource = DataSet1
    DataGridView1.DataMember = "customers"

    'add new row into datatable
    row = DataSet1.Tables("customers").NewRow()
    row.Item(0) = "firstName"
    row.Item(1) = "lastName"
    row.Item(2) = "phone"
    DataSet1.Tables("customers").Rows.Add(row)

    'update data
    SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
    SqlCommand1.CommandText = "select * from customers "
    SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
    SqlDataAdapter1.Update(DataSet1, "customers")

    Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!

    V T P 3 Replies Last reply
    0
    • C cotdot11111

      i have 2 following solution the first

      sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
      SqlCommand1.ExecuteNonQuery()

      the second

      'fill into datagridview
      SqlCommand1.CommandText = "select * from customers "
      SqlDataAdapter1.SelectCommand = SqlCommand1
      SqlDataAdapter1.Fill(DataSet1, "customers")
      DataGridView1.DataSource = DataSet1
      DataGridView1.DataMember = "customers"

      'add new row into datatable
      row = DataSet1.Tables("customers").NewRow()
      row.Item(0) = "firstName"
      row.Item(1) = "lastName"
      row.Item(2) = "phone"
      DataSet1.Tables("customers").Rows.Add(row)

      'update data
      SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
      SqlCommand1.CommandText = "select * from customers "
      SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
      SqlDataAdapter1.Update(DataSet1, "customers")

      Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!

      V Offline
      V Offline
      Vimalsoft Pty Ltd
      wrote on last edited by
      #2

      These two are doing different things, You cant Compare them. I suggest you buy a Book

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

      1 Reply Last reply
      0
      • C cotdot11111

        i have 2 following solution the first

        sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
        SqlCommand1.ExecuteNonQuery()

        the second

        'fill into datagridview
        SqlCommand1.CommandText = "select * from customers "
        SqlDataAdapter1.SelectCommand = SqlCommand1
        SqlDataAdapter1.Fill(DataSet1, "customers")
        DataGridView1.DataSource = DataSet1
        DataGridView1.DataMember = "customers"

        'add new row into datatable
        row = DataSet1.Tables("customers").NewRow()
        row.Item(0) = "firstName"
        row.Item(1) = "lastName"
        row.Item(2) = "phone"
        DataSet1.Tables("customers").Rows.Add(row)

        'update data
        SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
        SqlCommand1.CommandText = "select * from customers "
        SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
        SqlDataAdapter1.Update(DataSet1, "customers")

        Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!

        T Offline
        T Offline
        The Man from U N C L E
        wrote on last edited by
        #3

        I see a lot of this. Clearly the first is better etc. Why bother filling a dataset in order to perform an insert? The second option will produce the same SQL at the end of the day, but at high cost in processing to generating something you can type yourself in seconds.

        If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]

        1 Reply Last reply
        0
        • C cotdot11111

          i have 2 following solution the first

          sqlcommand1.commandText = "insert into customers values('firstName','lastName','phone')
          SqlCommand1.ExecuteNonQuery()

          the second

          'fill into datagridview
          SqlCommand1.CommandText = "select * from customers "
          SqlDataAdapter1.SelectCommand = SqlCommand1
          SqlDataAdapter1.Fill(DataSet1, "customers")
          DataGridView1.DataSource = DataSet1
          DataGridView1.DataMember = "customers"

          'add new row into datatable
          row = DataSet1.Tables("customers").NewRow()
          row.Item(0) = "firstName"
          row.Item(1) = "lastName"
          row.Item(2) = "phone"
          DataSet1.Tables("customers").Rows.Add(row)

          'update data
          SqlCommandBuilder1 = New SqlCommandBuilder(SqlDataAdapter1)
          SqlCommand1.CommandText = "select * from customers "
          SqlDataAdapter1.InsertCommand = SqlCommandBuilder1.GetInsertCommand
          SqlDataAdapter1.Update(DataSet1, "customers")

          Can you tell me what 's difference between those ? And which is solution with higher performance :doh: Thank you very much!!

          P Offline
          P Offline
          plecco
          wrote on last edited by
          #4

          The first one is a little better than the second b/c your using a bit more processing power on your app server to create the dataset you have on the second. In the first, most of the processing will be performed on the database server which is optimized for doing such computations.

          Plecco Technologies, Inc. Web Design | Software Development | Internet Marketing

          modified on Wednesday, January 27, 2010 10:01 AM

          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