read sql record into memory, use/modify fields then save changes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cj

    read sql record into memory, use/modify fields then save changes

    How is the best way to return a single record via sql query that will
    result in me being able to read and change the values of the individual
    fields as needed as I proceed through a section of code?

    Once this section of code is completed that record's changed will need
    to be flushed back to the table it was pulled from. This process will
    NOT involve a user interface.

    I've written queries to get info for a datagrid before and I've written
    queries to update records before but storing and reading/changing a
    record then flushing it back is new to me in VB.

    I'm using VB 2008.
  • zacks@construction-imaging.com

    #2
    Re: read sql record into memory, use/modify fields then save changes

    On Mar 25, 2:31 pm, cj <c...@nospam.no spamwrote:
    How is the best way to return a single record via sql query that will
    result in me being able to read and change the values of the individual
    fields as needed as I proceed through a section of code?
    >
    Once this section of code is completed that record's changed will need
    to be flushed back to the table it was pulled from.  This process will
    NOT involve a user interface.
    >
    I've written queries to get info for a datagrid before and I've written
    queries to update records before but storing and reading/changing a
    record then flushing it back is new to me in VB.
    >
    I'm using VB 2008.
    SQLDataAdaptor maybe?

    Comment

    • Cor Ligthert[MVP]

      #3
      Re: read sql record into memory, use/modify fields then save changes

      cj,


      A simple sqlConnection that has the Select statement and the connection
      A simple datatable that you get with fill
      A simple sqlCommandbuild er which you let get the information from that
      \\\
      dim cmd as new SqlCommandBuild er(yourdatadapt er)
      ///
      A a simple update with the same tableadapter with the changed row
      And you are ready.


      Another approach is creatinging an SQL Datareader with the same select
      statement
      To read one row
      To create an SQL transact statement (which is mostly the most time consuming
      in SQL transact code)
      set all the parameters (the other bunch of work)
      create an command (with the update command)
      do an command.execute nonquerry


      A third approach probably most simple is
      Create a datacontext (dbml)
      Create a Linq statement to select the data
      do a datacontext submitchanges

      There are more

      Cor


      "cj" <cj@nospam.nosp amschreef in bericht
      news:OTzPoZqjIH A.4396@TK2MSFTN GP04.phx.gbl...
      How is the best way to return a single record via sql query that will
      result in me being able to read and change the values of the individual
      fields as needed as I proceed through a section of code?
      >
      Once this section of code is completed that record's changed will need to
      be flushed back to the table it was pulled from. This process will NOT
      involve a user interface.
      >
      I've written queries to get info for a datagrid before and I've written
      queries to update records before but storing and reading/changing a record
      then flushing it back is new to me in VB.
      >
      I'm using VB 2008.

      Comment

      Working...