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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Updating table using SelectCommand.CommandText?

Updating table using SelectCommand.CommandText?

Scheduled Pinned Locked Moved Visual Basic
databasequestionhelpannouncement
2 Posts 2 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.
  • R Offline
    R Offline
    Rashar
    wrote on last edited by
    #1

    Hello, I have tried the code below to update my table, but I'm not sure if it is in the right context... The problem that I am facing is that my data is being passed to the table, but it creates a new row as oppose to updating the row that I specified... and I think that is coming from the line that reads myLocalDataSet.Tables("tblCall_Reports").Rows.Add() How can I modify this code so that it will update my table based on the SQL criteria? 'Save changes to the database myLocalSqlDataAdapter.SelectCommand.CommandText = "SELECT * FROM tblCall_Reports WHERE UID = " & txtUID.Text myLocalDataSet.Tables("tblCall_Reports").Rows.Add() myLocalSqlDataAdapter.Update(myLocalDataSet, "tblCall_Reports") Thanks in advance, Rashar

    K 1 Reply Last reply
    0
    • R Rashar

      Hello, I have tried the code below to update my table, but I'm not sure if it is in the right context... The problem that I am facing is that my data is being passed to the table, but it creates a new row as oppose to updating the row that I specified... and I think that is coming from the line that reads myLocalDataSet.Tables("tblCall_Reports").Rows.Add() How can I modify this code so that it will update my table based on the SQL criteria? 'Save changes to the database myLocalSqlDataAdapter.SelectCommand.CommandText = "SELECT * FROM tblCall_Reports WHERE UID = " & txtUID.Text myLocalDataSet.Tables("tblCall_Reports").Rows.Add() myLocalSqlDataAdapter.Update(myLocalDataSet, "tblCall_Reports") Thanks in advance, Rashar

      K Offline
      K Offline
      kumarprabhakar74
      wrote on last edited by
      #2

      You can use following command to update table with select statement Dim sqlString As String = "select * from employee where id=1" Dim comm As New SqlCommand(sqlString, conn) Dim adp As New SqlDataAdapter Dim sb As New SqlCommandBuilder(adp) adp.SelectCommand = comm Dim ds As New DataSet adp.Fill(ds) row(3) = "Dealer" adp.Update(ds) Kumar Prabhakar

      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