Q: Updating

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

    #1

    Q: Updating

    Hi

    This question has just occurred to me and I'm hoping somebody can help me.

    Suppose I have a table in an Access database. I have access to this table
    via a data adaptor i.e. I create a data adaptor to the table, create the
    update, delete etc. commands using a command builder and then fill a dataset
    with the table.

    My question is, if I add a column to the tables in the dataset, and then do
    an update, will the new column appear in the source table in the Access
    database?

    The reason I'm uncertain as to whether it would happen is because the
    update, insert, delete etc. commands are generated before the new column has
    been created. If this is the case, how can the table be updated with the new
    column?

    Hope somebody can clarify things for me?

    Geoff


  • Cor Ligthert [MVP]

    #2
    Re: Updating

    Geoff,

    AFAIK uses the commandbuilder the columns it gets from the select.

    Therefore only those columns will be updated.

    There will never been build a table in your database by a adonet command by
    the way, with the exception of an execute.nonquir y supplying a SQL Create or
    Alter statement.

    I hope this helps,

    Cor

    "Geoff" <nodamnspam@ema il.com> schreef in bericht
    news:4341730a$0 $3624$cc9e4d1f@ news.dial.pipex .com...[color=blue]
    > Hi
    >
    > This question has just occurred to me and I'm hoping somebody can help me.
    >
    > Suppose I have a table in an Access database. I have access to this table
    > via a data adaptor i.e. I create a data adaptor to the table, create the
    > update, delete etc. commands using a command builder and then fill a
    > dataset with the table.
    >
    > My question is, if I add a column to the tables in the dataset, and then
    > do an update, will the new column appear in the source table in the Access
    > database?
    >
    > The reason I'm uncertain as to whether it would happen is because the
    > update, insert, delete etc. commands are generated before the new column
    > has been created. If this is the case, how can the table be updated with
    > the new column?
    >
    > Hope somebody can clarify things for me?
    >
    > Geoff
    >[/color]


    Comment

    • Geoff

      #3
      Re: Updating

      Hi Cor

      Do I understand you correctly i.e. there is now way to create a new column
      in a table in a database via an update command to a data adaptor (by adding
      a column to a table of a dataset and then doing the update)?

      Geoff

      "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
      news:OA9nwaNyFH A.3152@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Geoff,
      >
      > AFAIK uses the commandbuilder the columns it gets from the select.
      >
      > Therefore only those columns will be updated.
      >
      > There will never been build a table in your database by a adonet command
      > by the way, with the exception of an execute.nonquir y supplying a SQL
      > Create or Alter statement.
      >
      > I hope this helps,
      >
      > Cor
      >
      > "Geoff" <nodamnspam@ema il.com> schreef in bericht
      > news:4341730a$0 $3624$cc9e4d1f@ news.dial.pipex .com...[color=green]
      >> Hi
      >>
      >> This question has just occurred to me and I'm hoping somebody can help
      >> me.
      >>
      >> Suppose I have a table in an Access database. I have access to this table
      >> via a data adaptor i.e. I create a data adaptor to the table, create the
      >> update, delete etc. commands using a command builder and then fill a
      >> dataset with the table.
      >>
      >> My question is, if I add a column to the tables in the dataset, and then
      >> do an update, will the new column appear in the source table in the
      >> Access database?
      >>
      >> The reason I'm uncertain as to whether it would happen is because the
      >> update, insert, delete etc. commands are generated before the new column
      >> has been created. If this is the case, how can the table be updated with
      >> the new column?
      >>
      >> Hope somebody can clarify things for me?
      >>
      >> Geoff
      >>[/color]
      >
      >[/color]


      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Updating

        Geoff,

        No however doing it with SQL code is absolute no hell of a job using the
        Alter Table Sql code.

        http://msdn.microsoft.com/library/de...aa-az_3ied.asp

        And than process this with executenonquery .

        \\\
        dim conn as new sqlconnections( connectionstrin g)
        dim cmd as new sqlcommand(sqls tring, conn)
        open.conn
        cmd.executenonq uery
        close.conn
        ///

        I hope this helps,

        Cor


        "Geoff" <nodamnspam@ema il.com> schreef in bericht
        news:4342b939$0 $22441$cc9e4d1f @news.dial.pipe x.com...[color=blue]
        > Hi Cor
        >
        > Do I understand you correctly i.e. there is now way to create a new column
        > in a table in a database via an update command to a data adaptor (by
        > adding a column to a table of a dataset and then doing the update)?
        >
        > Geoff
        >
        > "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
        > news:OA9nwaNyFH A.3152@TK2MSFTN GP10.phx.gbl...[color=green]
        >> Geoff,
        >>
        >> AFAIK uses the commandbuilder the columns it gets from the select.
        >>
        >> Therefore only those columns will be updated.
        >>
        >> There will never been build a table in your database by a adonet command
        >> by the way, with the exception of an execute.nonquir y supplying a SQL
        >> Create or Alter statement.
        >>
        >> I hope this helps,
        >>
        >> Cor
        >>
        >> "Geoff" <nodamnspam@ema il.com> schreef in bericht
        >> news:4341730a$0 $3624$cc9e4d1f@ news.dial.pipex .com...[color=darkred]
        >>> Hi
        >>>
        >>> This question has just occurred to me and I'm hoping somebody can help
        >>> me.
        >>>
        >>> Suppose I have a table in an Access database. I have access to this
        >>> table via a data adaptor i.e. I create a data adaptor to the table,
        >>> create the update, delete etc. commands using a command builder and then
        >>> fill a dataset with the table.
        >>>
        >>> My question is, if I add a column to the tables in the dataset, and then
        >>> do an update, will the new column appear in the source table in the
        >>> Access database?
        >>>
        >>> The reason I'm uncertain as to whether it would happen is because the
        >>> update, insert, delete etc. commands are generated before the new column
        >>> has been created. If this is the case, how can the table be updated with
        >>> the new column?
        >>>
        >>> Hope somebody can clarify things for me?
        >>>
        >>> Geoff
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Geoff

          #5
          Re: Updating

          Hi Cor

          Very interesting as usual. Thanks. However, this spurs me on to another,
          related question:

          Suppose you have two tables; not necessarily with the same fields. You can
          load these tables into a dataset quite easily. You can even Merge the two
          tables together, However, it appears that after merging the tables you
          cannot upload the resulting table "back" to one of the original tables.

          Is this correct?

          Geoff

          "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
          news:OAulAmQyFH A.1856@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Geoff,
          >
          > No however doing it with SQL code is absolute no hell of a job using the
          > Alter Table Sql code.
          >
          > http://msdn.microsoft.com/library/de...aa-az_3ied.asp
          >
          > And than process this with executenonquery .
          >
          > \\\
          > dim conn as new sqlconnections( connectionstrin g)
          > dim cmd as new sqlcommand(sqls tring, conn)
          > open.conn
          > cmd.executenonq uery
          > close.conn
          > ///
          >
          > I hope this helps,
          >
          > Cor
          >
          >
          > "Geoff" <nodamnspam@ema il.com> schreef in bericht
          > news:4342b939$0 $22441$cc9e4d1f @news.dial.pipe x.com...[color=green]
          >> Hi Cor
          >>
          >> Do I understand you correctly i.e. there is now way to create a new
          >> column in a table in a database via an update command to a data adaptor
          >> (by adding a column to a table of a dataset and then doing the update)?
          >>
          >> Geoff
          >>
          >> "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
          >> news:OA9nwaNyFH A.3152@TK2MSFTN GP10.phx.gbl...[color=darkred]
          >>> Geoff,
          >>>
          >>> AFAIK uses the commandbuilder the columns it gets from the select.
          >>>
          >>> Therefore only those columns will be updated.
          >>>
          >>> There will never been build a table in your database by a adonet command
          >>> by the way, with the exception of an execute.nonquir y supplying a SQL
          >>> Create or Alter statement.
          >>>
          >>> I hope this helps,
          >>>
          >>> Cor
          >>>
          >>> "Geoff" <nodamnspam@ema il.com> schreef in bericht
          >>> news:4341730a$0 $3624$cc9e4d1f@ news.dial.pipex .com...
          >>>> Hi
          >>>>
          >>>> This question has just occurred to me and I'm hoping somebody can help
          >>>> me.
          >>>>
          >>>> Suppose I have a table in an Access database. I have access to this
          >>>> table via a data adaptor i.e. I create a data adaptor to the table,
          >>>> create the update, delete etc. commands using a command builder and
          >>>> then fill a dataset with the table.
          >>>>
          >>>> My question is, if I add a column to the tables in the dataset, and
          >>>> then do an update, will the new column appear in the source table in
          >>>> the Access database?
          >>>>
          >>>> The reason I'm uncertain as to whether it would happen is because the
          >>>> update, insert, delete etc. commands are generated before the new
          >>>> column has been created. If this is the case, how can the table be
          >>>> updated with the new column?
          >>>>
          >>>> Hope somebody can clarify things for me?
          >>>>
          >>>> Geoff
          >>>>
          >>>
          >>>[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Updating

            Geoff,
            [color=blue]
            >
            > Suppose you have two tables; not necessarily with the same fields. You can
            > load these tables into a dataset quite easily. You can even Merge the two
            > tables together, However, it appears that after merging the tables you
            > cannot upload the resulting table "back" to one of the original tables.
            >
            > Is this correct?
            >[/color]
            As long as that the columns are in the database table you can do everything
            you want with the merged table as long that you create the right
            DeleteCommand, InsertCommand and UpdateCommand in the DataAdapter.

            http://msdn.microsoft.com/library/de...mberstopic.asp

            I hope that this is what you mean?

            Cor




            Comment

            • Geoff

              #7
              Re: Updating

              Yes, thanks so much Cor.

              Geoff

              "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
              news:%23y8N2YRy FHA.3000@TK2MSF TNGP12.phx.gbl. ..[color=blue]
              > Geoff,
              >[color=green]
              >>
              >> Suppose you have two tables; not necessarily with the same fields. You
              >> can load these tables into a dataset quite easily. You can even Merge the
              >> two tables together, However, it appears that after merging the tables
              >> you cannot upload the resulting table "back" to one of the original
              >> tables.
              >>
              >> Is this correct?
              >>[/color]
              > As long as that the columns are in the database table you can do
              > everything you want with the merged table as long that you create the
              > right DeleteCommand, InsertCommand and UpdateCommand in the DataAdapter.
              >
              > http://msdn.microsoft.com/library/de...mberstopic.asp
              >
              > I hope that this is what you mean?
              >
              > Cor
              >
              >
              >
              >[/color]


              Comment

              Working...