Commiting db changes

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

    Commiting db changes

    What am I missing here? Based on what the help files tell me, it seems like
    my code should look like this:

    libraryTableAda pter1.Fill(libr ary1._Library);
    libraryTableAda pter1.Insert(re sult, 1, 0, 0, 0, 0, "",
    "", "", "", 2000);
    libraryTableAda pter1.Update(li brary1._Library );
    library1._Libra ry.AcceptChange s();

    When my program finishes, however, there is nothing new. The row was never
    added to the actual db.

    libraryTableAda pter1 is a TableAdapter
    library1 is a DataSet
    result is a string

    PS: This is in VS2005.
  • Bruce Wood

    #2
    Re: Commiting db changes

    Why would you involve the TableAdapter in the Insert operation? I would
    think that you would Insert into a particular DataTable within your
    DataSet, then call TableAdapter.Up date to write that change back to the
    database.

    Comment

    • mmxbass

      #3
      Re: Commiting db changes

      Because that is what
      ms-help://MS.MSDNQTR.v80. en/MS.MSDN.v80/MS.VisualStudio .v80.en/dv_raddata/html/012c5924-91f7-4790-b2a6-f51402b7014b.ht m
      from the VS2005 help file seems to be telling me to do.

      "Bruce Wood" wrote:
      [color=blue]
      > Why would you involve the TableAdapter in the Insert operation? I would
      > think that you would Insert into a particular DataTable within your
      > DataSet, then call TableAdapter.Up date to write that change back to the
      > database.
      >
      >[/color]

      Comment

      • Bart Mermuys

        #4
        Re: Commiting db changes

        Hi,

        "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
        news:58CA0D5A-1579-412F-B299-A970A55759FA@mi crosoft.com...[color=blue]
        > What am I missing here? Based on what the help files tell me, it seems
        > like
        > my code should look like this:
        >
        > libraryTableAda pter1.Fill(libr ary1._Library);
        > libraryTableAda pter1.Insert(re sult, 1, 0, 0, 0, 0, "",
        > "", "", "", 2000);
        > libraryTableAda pter1.Update(li brary1._Library );
        > library1._Libra ry.AcceptChange s();
        >
        > When my program finishes, however, there is nothing new. The row was never
        > added to the actual db.[/color]

        It should either be :
        libraryTableAda pter1.Fill(libr ary1._Library);
        library1._Libra ry.Add_LibraryR ow( ... );
        libraryTableAda pter1.Update(li brary1._Library );
        - or -
        libraryTableAda pter.Insert( ... );

        So you shoudln't confuse them. Offcourse it doesn't really explain why
        TableAdapter.In sert didn't work. What DB are you using ?

        HTH,
        Greetings



        [color=blue]
        >
        > libraryTableAda pter1 is a TableAdapter
        > library1 is a DataSet
        > result is a string
        >
        > PS: This is in VS2005.[/color]


        Comment

        • mmxbass

          #5
          Re: Commiting db changes

          I'm using an MS access table that I brought in to the project with the add
          new data source wizard. Reading the DB works a-ok. Writing is the big problem
          here. Nothing seems to take.

          "Bart Mermuys" wrote:
          [color=blue]
          > Hi,
          >
          > "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
          > news:58CA0D5A-1579-412F-B299-A970A55759FA@mi crosoft.com...[color=green]
          > > What am I missing here? Based on what the help files tell me, it seems
          > > like
          > > my code should look like this:
          > >
          > > libraryTableAda pter1.Fill(libr ary1._Library);
          > > libraryTableAda pter1.Insert(re sult, 1, 0, 0, 0, 0, "",
          > > "", "", "", 2000);
          > > libraryTableAda pter1.Update(li brary1._Library );
          > > library1._Libra ry.AcceptChange s();
          > >
          > > When my program finishes, however, there is nothing new. The row was never
          > > added to the actual db.[/color]
          >
          > It should either be :
          > libraryTableAda pter1.Fill(libr ary1._Library);
          > library1._Libra ry.Add_LibraryR ow( ... );
          > libraryTableAda pter1.Update(li brary1._Library );
          > - or -
          > libraryTableAda pter.Insert( ... );
          >
          > So you shoudln't confuse them. Offcourse it doesn't really explain why
          > TableAdapter.In sert didn't work. What DB are you using ?
          >
          > HTH,
          > Greetings
          >
          >
          >
          >[color=green]
          > >
          > > libraryTableAda pter1 is a TableAdapter
          > > library1 is a DataSet
          > > result is a string
          > >
          > > PS: This is in VS2005.[/color]
          >
          >
          >[/color]

          Comment

          • Bart Mermuys

            #6
            Re: Commiting db changes

            Hi,

            "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
            news:D245C5BF-A0C8-4A10-AF51-E2FECBB6B586@mi crosoft.com...[color=blue]
            > I'm using an MS access table that I brought in to the project with the add
            > new data source wizard. Reading the DB works a-ok.[/color]

            If the .mdb is part of the project (visible in solution explorer) then it
            will (most likely) be copied to the bin\debug folder when you execute the
            application from within vs. The application will use the .mdb in the
            bin\debug folder. So the next time your app runs vs overwrites the .mdb and
            your previous made changes are lost.

            One thing you can do is open App.config file, look for ConnectionStrin g and
            change "|DataDirectory |\yourdb.mdb" into "..\..\yourdb.m db". This way it
            will directly use the .mdb that is in the project diectory (instead of of a
            new copy).


            HTH,
            Greetings

            [color=blue]
            >Writing is the big problem
            > here. Nothing seems to take.
            >
            > "Bart Mermuys" wrote:
            >[color=green]
            >> Hi,
            >>
            >> "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
            >> news:58CA0D5A-1579-412F-B299-A970A55759FA@mi crosoft.com...[color=darkred]
            >> > What am I missing here? Based on what the help files tell me, it seems
            >> > like
            >> > my code should look like this:
            >> >
            >> > libraryTableAda pter1.Fill(libr ary1._Library);
            >> > libraryTableAda pter1.Insert(re sult, 1, 0, 0, 0, 0,
            >> > "",
            >> > "", "", "", 2000);
            >> > libraryTableAda pter1.Update(li brary1._Library );
            >> > library1._Libra ry.AcceptChange s();
            >> >
            >> > When my program finishes, however, there is nothing new. The row was
            >> > never
            >> > added to the actual db.[/color]
            >>
            >> It should either be :
            >> libraryTableAda pter1.Fill(libr ary1._Library);
            >> library1._Libra ry.Add_LibraryR ow( ... );
            >> libraryTableAda pter1.Update(li brary1._Library );
            >> - or -
            >> libraryTableAda pter.Insert( ... );
            >>
            >> So you shoudln't confuse them. Offcourse it doesn't really explain why
            >> TableAdapter.In sert didn't work. What DB are you using ?
            >>
            >> HTH,
            >> Greetings
            >>
            >>
            >>
            >>[color=darkred]
            >> >
            >> > libraryTableAda pter1 is a TableAdapter
            >> > library1 is a DataSet
            >> > result is a string
            >> >
            >> > PS: This is in VS2005.[/color]
            >>
            >>
            >>[/color][/color]


            Comment

            • mmxbass

              #7
              Re: Commiting db changes

              <h1>??!?! 0_o</h1>
              I can't belive I didn't notice that. You're totally right. The origional
              code actually does work fine. Visual studio just overrides it with the
              origional file every time I rerun the program.

              Thank you so much.

              "Bart Mermuys" wrote:
              [color=blue]
              > Hi,
              >
              > "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
              > news:D245C5BF-A0C8-4A10-AF51-E2FECBB6B586@mi crosoft.com...[color=green]
              > > I'm using an MS access table that I brought in to the project with the add
              > > new data source wizard. Reading the DB works a-ok.[/color]
              >
              > If the .mdb is part of the project (visible in solution explorer) then it
              > will (most likely) be copied to the bin\debug folder when you execute the
              > application from within vs. The application will use the .mdb in the
              > bin\debug folder. So the next time your app runs vs overwrites the .mdb and
              > your previous made changes are lost.
              >
              > One thing you can do is open App.config file, look for ConnectionStrin g and
              > change "|DataDirectory |\yourdb.mdb" into "..\..\yourdb.m db". This way it
              > will directly use the .mdb that is in the project diectory (instead of of a
              > new copy).
              >
              >
              > HTH,
              > Greetings
              >
              >[color=green]
              > >Writing is the big problem
              > > here. Nothing seems to take.
              > >
              > > "Bart Mermuys" wrote:
              > >[color=darkred]
              > >> Hi,
              > >>
              > >> "mmxbass" <mmxbass@discus sions.microsoft .com> wrote in message
              > >> news:58CA0D5A-1579-412F-B299-A970A55759FA@mi crosoft.com...
              > >> > What am I missing here? Based on what the help files tell me, it seems
              > >> > like
              > >> > my code should look like this:
              > >> >
              > >> > libraryTableAda pter1.Fill(libr ary1._Library);
              > >> > libraryTableAda pter1.Insert(re sult, 1, 0, 0, 0, 0,
              > >> > "",
              > >> > "", "", "", 2000);
              > >> > libraryTableAda pter1.Update(li brary1._Library );
              > >> > library1._Libra ry.AcceptChange s();
              > >> >
              > >> > When my program finishes, however, there is nothing new. The row was
              > >> > never
              > >> > added to the actual db.
              > >>
              > >> It should either be :
              > >> libraryTableAda pter1.Fill(libr ary1._Library);
              > >> library1._Libra ry.Add_LibraryR ow( ... );
              > >> libraryTableAda pter1.Update(li brary1._Library );
              > >> - or -
              > >> libraryTableAda pter.Insert( ... );
              > >>
              > >> So you shoudln't confuse them. Offcourse it doesn't really explain why
              > >> TableAdapter.In sert didn't work. What DB are you using ?
              > >>
              > >> HTH,
              > >> Greetings
              > >>
              > >>
              > >>
              > >>
              > >> >
              > >> > libraryTableAda pter1 is a TableAdapter
              > >> > library1 is a DataSet
              > >> > result is a string
              > >> >
              > >> > PS: This is in VS2005.
              > >>
              > >>
              > >>[/color][/color]
              >
              >
              >[/color]

              Comment

              Working...