Defaultvalue from database in dataset columns

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

    Defaultvalue from database in dataset columns

    Hi,

    I have an Access database in which I defined default values for certain
    columns. On my windows forms I've got controls bound to the dataset, The
    problem is that when I add a new row to the dataset my controls don't have
    the defaultvalue entered in the database.

    Is it possible to retrieve the defaultvalue for the column from the
    database?


    --
    Met vriendelijke groet / With regards / Saludos,
    Moviat Automatisering


    Maurice Mertens
    mauricem@moviat _KillSpamWordFo rEMail.nl

    tel: +31 162 470 534
    fax: +31 162 470 502
  • William Ryan eMVP

    #2
    Re: Defaultvalue from database in dataset columns

    The Datacolumn object has a defaultvalue property.. Say that Column1 in your
    Db named FirstCol has a defaultvalue of "1" in Access..

    assuming FirstCol was the first field in your SQL Query..

    myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"

    You can do that for each one locally so it matches your defaults in the db.
    "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
    news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=blue]
    > Hi,
    >
    > I have an Access database in which I defined default values for certain
    > columns. On my windows forms I've got controls bound to the dataset, The
    > problem is that when I add a new row to the dataset my controls don't have
    > the defaultvalue entered in the database.
    >
    > Is it possible to retrieve the defaultvalue for the column from the
    > database?
    >
    >
    > --
    > Met vriendelijke groet / With regards / Saludos,
    > Moviat Automatisering
    >
    >
    > Maurice Mertens
    > mauricem@moviat _KillSpamWordFo rEMail.nl
    >
    > tel: +31 162 470 534
    > fax: +31 162 470 502[/color]


    Comment

    • William Ryan eMVP

      #3
      Re: Defaultvalue from database in dataset columns

      The Datacolumn object has a defaultvalue property.. Say that Column1 in your
      Db named FirstCol has a defaultvalue of "1" in Access..

      assuming FirstCol was the first field in your SQL Query..

      myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"

      You can do that for each one locally so it matches your defaults in the db.
      "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
      news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=blue]
      > Hi,
      >
      > I have an Access database in which I defined default values for certain
      > columns. On my windows forms I've got controls bound to the dataset, The
      > problem is that when I add a new row to the dataset my controls don't have
      > the defaultvalue entered in the database.
      >
      > Is it possible to retrieve the defaultvalue for the column from the
      > database?
      >
      >
      > --
      > Met vriendelijke groet / With regards / Saludos,
      > Moviat Automatisering
      >
      >
      > Maurice Mertens
      > mauricem@moviat _KillSpamWordFo rEMail.nl
      >
      > tel: +31 162 470 534
      > fax: +31 162 470 502[/color]


      Comment

      • Maurice Mertens

        #4
        Re: Defaultvalue from database in dataset columns

        Hi William,

        Indeed it is possible to set them manually but isn't it possible for .NET
        to set the defaultvalue of the control on the form automatically with the
        defaultvalue from the database.

        This because when I change the defaultvalue in de database I don't have
        to edit my code.





        "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
        news:e5CNdc6JEH A.3628@TK2MSFTN GP12.phx.gbl:
        [color=blue]
        > The Datacolumn object has a defaultvalue property.. Say that Column1
        > in your Db named FirstCol has a defaultvalue of "1" in Access..
        >
        > assuming FirstCol was the first field in your SQL Query..
        >
        > myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"
        >
        > You can do that for each one locally so it matches your defaults in
        > the db. "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl>
        > wrote in message news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=green]
        >> Hi,
        >>
        >> I have an Access database in which I defined default values for
        >> certain columns. On my windows forms I've got controls bound to the
        >> dataset, The problem is that when I add a new row to the dataset my
        >> controls don't have the defaultvalue entered in the database.
        >>
        >> Is it possible to retrieve the defaultvalue for the column from the
        >> database?
        >>
        >>
        >> --
        >> Met vriendelijke groet / With regards / Saludos,
        >> Moviat Automatisering
        >>
        >>
        >> Maurice Mertens
        >> mauricem@moviat _KillSpamWordFo rEMail.nl
        >>
        >> tel: +31 162 470 534
        >> fax: +31 162 470 502[/color]
        >
        >
        >[/color]





        --
        Met vriendelijke groet / With regards / Saludos,
        Moviat Automatisering


        Maurice Mertens
        mauricem@moviat _KillSpamWordFo rEMail.nl

        tel: +31 162 470 534
        fax: +31 162 470 502

        Comment

        • Maurice Mertens

          #5
          Re: Defaultvalue from database in dataset columns

          Hi William,

          Indeed it is possible to set them manually but isn't it possible for .NET
          to set the defaultvalue of the control on the form automatically with the
          defaultvalue from the database.

          This because when I change the defaultvalue in de database I don't have
          to edit my code.





          "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
          news:e5CNdc6JEH A.3628@TK2MSFTN GP12.phx.gbl:
          [color=blue]
          > The Datacolumn object has a defaultvalue property.. Say that Column1
          > in your Db named FirstCol has a defaultvalue of "1" in Access..
          >
          > assuming FirstCol was the first field in your SQL Query..
          >
          > myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"
          >
          > You can do that for each one locally so it matches your defaults in
          > the db. "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl>
          > wrote in message news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=green]
          >> Hi,
          >>
          >> I have an Access database in which I defined default values for
          >> certain columns. On my windows forms I've got controls bound to the
          >> dataset, The problem is that when I add a new row to the dataset my
          >> controls don't have the defaultvalue entered in the database.
          >>
          >> Is it possible to retrieve the defaultvalue for the column from the
          >> database?
          >>
          >>
          >> --
          >> Met vriendelijke groet / With regards / Saludos,
          >> Moviat Automatisering
          >>
          >>
          >> Maurice Mertens
          >> mauricem@moviat _KillSpamWordFo rEMail.nl
          >>
          >> tel: +31 162 470 534
          >> fax: +31 162 470 502[/color]
          >
          >
          >[/color]





          --
          Met vriendelijke groet / With regards / Saludos,
          Moviat Automatisering


          Maurice Mertens
          mauricem@moviat _KillSpamWordFo rEMail.nl

          tel: +31 162 470 534
          fax: +31 162 470 502

          Comment

          • William Ryan eMVP

            #6
            Re: Defaultvalue from database in dataset columns

            I may be confused. You are adding new records locally to a datatable and
            you want the a given default value to appear when you first add a new row.
            For each column that has a default value in the DB, (if your query is Select
            first, second, third, forth from MyTable) and first, and forth have a
            default of "Default", then do this...

            myDatatable.Col umns[0].DefaultValue = "Default";
            myDatatable.Col umns[3].DefaultValue = "Default";

            Now when you add a new value you are good to go. Unless I'm
            misunderstandin g, this should solve the problem. Default values don't
            usually change in a db and they're not going to change during a user session
            so setting them at the onset shouldn't be a big deal. Moreover, if you were
            to leave the defaults out, and submit your update, they'd be added by the DB
            when the insert happened and if you had the refresh dataset option on or
            insert logic that refreshed for you, the new values would apper in your app.
            Functionally, there'd be little difference. However, if you want the fields
            in the app to have the default value before they go to the db (so the user
            will see exactly what's going to be in the db) , then set the DefaultValue
            property in the column to match its counterpart in the db

            I admit though that I may be misunderstandin g so if I am,please let me know
            and I'll do my best.

            Cheers,

            BIll

            <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
            news:Xns94D2A62 4FD393mauricemm oviat@207.46.24 8.16...[color=blue]
            > Hi William,
            >
            > Indeed it is possible to set them manually but isn't it possible for .NET
            > to set the defaultvalue of the control on the form automatically with the
            > defaultvalue from the database.
            >
            > This because when I change the defaultvalue in de database I don't have
            > to edit my code.
            >
            >
            >
            >
            >
            > "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
            > news:e5CNdc6JEH A.3628@TK2MSFTN GP12.phx.gbl:
            >[color=green]
            > > The Datacolumn object has a defaultvalue property.. Say that Column1
            > > in your Db named FirstCol has a defaultvalue of "1" in Access..
            > >
            > > assuming FirstCol was the first field in your SQL Query..
            > >
            > > myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"
            > >
            > > You can do that for each one locally so it matches your defaults in
            > > the db. "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl>
            > > wrote in message news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=darkred]
            > >> Hi,
            > >>
            > >> I have an Access database in which I defined default values for
            > >> certain columns. On my windows forms I've got controls bound to the
            > >> dataset, The problem is that when I add a new row to the dataset my
            > >> controls don't have the defaultvalue entered in the database.
            > >>
            > >> Is it possible to retrieve the defaultvalue for the column from the
            > >> database?
            > >>
            > >>
            > >> --
            > >> Met vriendelijke groet / With regards / Saludos,
            > >> Moviat Automatisering
            > >>
            > >>
            > >> Maurice Mertens
            > >> mauricem@moviat _KillSpamWordFo rEMail.nl
            > >>
            > >> tel: +31 162 470 534
            > >> fax: +31 162 470 502[/color]
            > >
            > >
            > >[/color]
            >
            >
            >
            >
            >
            > --
            > Met vriendelijke groet / With regards / Saludos,
            > Moviat Automatisering
            >
            >
            > Maurice Mertens
            > mauricem@moviat _KillSpamWordFo rEMail.nl
            >
            > tel: +31 162 470 534
            > fax: +31 162 470 502[/color]


            Comment

            • William Ryan eMVP

              #7
              Re: Defaultvalue from database in dataset columns

              I may be confused. You are adding new records locally to a datatable and
              you want the a given default value to appear when you first add a new row.
              For each column that has a default value in the DB, (if your query is Select
              first, second, third, forth from MyTable) and first, and forth have a
              default of "Default", then do this...

              myDatatable.Col umns[0].DefaultValue = "Default";
              myDatatable.Col umns[3].DefaultValue = "Default";

              Now when you add a new value you are good to go. Unless I'm
              misunderstandin g, this should solve the problem. Default values don't
              usually change in a db and they're not going to change during a user session
              so setting them at the onset shouldn't be a big deal. Moreover, if you were
              to leave the defaults out, and submit your update, they'd be added by the DB
              when the insert happened and if you had the refresh dataset option on or
              insert logic that refreshed for you, the new values would apper in your app.
              Functionally, there'd be little difference. However, if you want the fields
              in the app to have the default value before they go to the db (so the user
              will see exactly what's going to be in the db) , then set the DefaultValue
              property in the column to match its counterpart in the db

              I admit though that I may be misunderstandin g so if I am,please let me know
              and I'll do my best.

              Cheers,

              BIll

              <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
              news:Xns94D2A62 4FD393mauricemm oviat@207.46.24 8.16...[color=blue]
              > Hi William,
              >
              > Indeed it is possible to set them manually but isn't it possible for .NET
              > to set the defaultvalue of the control on the form automatically with the
              > defaultvalue from the database.
              >
              > This because when I change the defaultvalue in de database I don't have
              > to edit my code.
              >
              >
              >
              >
              >
              > "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
              > news:e5CNdc6JEH A.3628@TK2MSFTN GP12.phx.gbl:
              >[color=green]
              > > The Datacolumn object has a defaultvalue property.. Say that Column1
              > > in your Db named FirstCol has a defaultvalue of "1" in Access..
              > >
              > > assuming FirstCol was the first field in your SQL Query..
              > >
              > > myDataSet.Table s["MyTable"].Column[0].DefaultValue = "1"
              > >
              > > You can do that for each one locally so it matches your defaults in
              > > the db. "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl>
              > > wrote in message news:Xns94D29C1 90E733mauricemm oviat@207.46.24 8.16...[color=darkred]
              > >> Hi,
              > >>
              > >> I have an Access database in which I defined default values for
              > >> certain columns. On my windows forms I've got controls bound to the
              > >> dataset, The problem is that when I add a new row to the dataset my
              > >> controls don't have the defaultvalue entered in the database.
              > >>
              > >> Is it possible to retrieve the defaultvalue for the column from the
              > >> database?
              > >>
              > >>
              > >> --
              > >> Met vriendelijke groet / With regards / Saludos,
              > >> Moviat Automatisering
              > >>
              > >>
              > >> Maurice Mertens
              > >> mauricem@moviat _KillSpamWordFo rEMail.nl
              > >>
              > >> tel: +31 162 470 534
              > >> fax: +31 162 470 502[/color]
              > >
              > >
              > >[/color]
              >
              >
              >
              >
              >
              > --
              > Met vriendelijke groet / With regards / Saludos,
              > Moviat Automatisering
              >
              >
              > Maurice Mertens
              > mauricem@moviat _KillSpamWordFo rEMail.nl
              >
              > tel: +31 162 470 534
              > fax: +31 162 470 502[/color]


              Comment

              • Maurice Mertens

                #8
                Re: Defaultvalue from database in dataset columns

                Hi Bill,

                actually I do have a database where the defaultvalue can change. In
                Microsoft Access it was possible to change the defaultvalue in the db so
                this new defaultvalue would also be the defaultvalue in the application
                (Without editing the code in the application).

                But it seems like this isn't possible in .NET.

                In your example when the defaultvalue from column[0] in the database
                changes to "NewDefault ", the application will still show "Default" as the
                defaultvalue for that column. The next step I have to make is edit the
                code in the application (in other words: a version update, I don't want
                that).

                thx for helping me out



                "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
                news:OLmfmS9JEH A.3216@tk2msftn gp13.phx.gbl:
                [color=blue]
                > I may be confused. You are adding new records locally to a datatable
                > and you want the a given default value to appear when you first add a
                > new row. For each column that has a default value in the DB, (if your
                > query is Select first, second, third, forth from MyTable) and first,
                > and forth have a default of "Default", then do this...
                >
                > myDatatable.Col umns[0].DefaultValue = "Default";
                > myDatatable.Col umns[3].DefaultValue = "Default";
                >
                > Now when you add a new value you are good to go. Unless I'm
                > misunderstandin g, this should solve the problem. Default values don't
                > usually change in a db and they're not going to change during a user
                > session so setting them at the onset shouldn't be a big deal.
                > Moreover, if you were to leave the defaults out, and submit your
                > update, they'd be added by the DB when the insert happened and if you
                > had the refresh dataset option on or insert logic that refreshed for
                > you, the new values would apper in your app. Functionally, there'd be
                > little difference. However, if you want the fields in the app to have
                > the default value before they go to the db (so the user will see
                > exactly what's going to be in the db) , then set the DefaultValue
                > property in the column to match its counterpart in the db
                >
                > I admit though that I may be misunderstandin g so if I am,please let me
                > know and I'll do my best.
                >
                > Cheers,
                >
                > BIll
                >[/color]

                --
                Met vriendelijke groet / With regards / Saludos,
                Moviat Automatisering


                Maurice Mertens
                mauricem@moviat _KillSpamWordFo rEMail.nl

                tel: +31 162 470 534
                fax: +31 162 470 502

                Comment

                • Maurice Mertens

                  #9
                  Re: Defaultvalue from database in dataset columns

                  Hi Bill,

                  actually I do have a database where the defaultvalue can change. In
                  Microsoft Access it was possible to change the defaultvalue in the db so
                  this new defaultvalue would also be the defaultvalue in the application
                  (Without editing the code in the application).

                  But it seems like this isn't possible in .NET.

                  In your example when the defaultvalue from column[0] in the database
                  changes to "NewDefault ", the application will still show "Default" as the
                  defaultvalue for that column. The next step I have to make is edit the
                  code in the application (in other words: a version update, I don't want
                  that).

                  thx for helping me out



                  "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
                  news:OLmfmS9JEH A.3216@tk2msftn gp13.phx.gbl:
                  [color=blue]
                  > I may be confused. You are adding new records locally to a datatable
                  > and you want the a given default value to appear when you first add a
                  > new row. For each column that has a default value in the DB, (if your
                  > query is Select first, second, third, forth from MyTable) and first,
                  > and forth have a default of "Default", then do this...
                  >
                  > myDatatable.Col umns[0].DefaultValue = "Default";
                  > myDatatable.Col umns[3].DefaultValue = "Default";
                  >
                  > Now when you add a new value you are good to go. Unless I'm
                  > misunderstandin g, this should solve the problem. Default values don't
                  > usually change in a db and they're not going to change during a user
                  > session so setting them at the onset shouldn't be a big deal.
                  > Moreover, if you were to leave the defaults out, and submit your
                  > update, they'd be added by the DB when the insert happened and if you
                  > had the refresh dataset option on or insert logic that refreshed for
                  > you, the new values would apper in your app. Functionally, there'd be
                  > little difference. However, if you want the fields in the app to have
                  > the default value before they go to the db (so the user will see
                  > exactly what's going to be in the db) , then set the DefaultValue
                  > property in the column to match its counterpart in the db
                  >
                  > I admit though that I may be misunderstandin g so if I am,please let me
                  > know and I'll do my best.
                  >
                  > Cheers,
                  >
                  > BIll
                  >[/color]

                  --
                  Met vriendelijke groet / With regards / Saludos,
                  Moviat Automatisering


                  Maurice Mertens
                  mauricem@moviat _KillSpamWordFo rEMail.nl

                  tel: +31 162 470 534
                  fax: +31 162 470 502

                  Comment

                  • William Ryan  eMVP

                    #10
                    Re: Defaultvalue from database in dataset columns

                    Maurice:

                    I didn't mean to imply that it never changes, but are you saying that the
                    default value or say the LastName column, where a defualt value might be
                    "Not Given" might change to Jones, then to Smith then to Ryan all in say one
                    session?
                    "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
                    news:Xns94D37CC 732D48mauricemm oviat@207.46.24 8.16...[color=blue]
                    > Hi Bill,
                    >
                    > actually I do have a database where the defaultvalue can change. In
                    > Microsoft Access it was possible to change the defaultvalue in the db so
                    > this new defaultvalue would also be the defaultvalue in the application
                    > (Without editing the code in the application).
                    >
                    > But it seems like this isn't possible in .NET.
                    >
                    > In your example when the defaultvalue from column[0] in the database
                    > changes to "NewDefault ", the application will still show "Default" as the
                    > defaultvalue for that column. The next step I have to make is edit the
                    > code in the application (in other words: a version update, I don't want
                    > that).
                    >
                    > thx for helping me out
                    >
                    >
                    >
                    > "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
                    > news:OLmfmS9JEH A.3216@tk2msftn gp13.phx.gbl:
                    >[color=green]
                    > > I may be confused. You are adding new records locally to a datatable
                    > > and you want the a given default value to appear when you first add a
                    > > new row. For each column that has a default value in the DB, (if your
                    > > query is Select first, second, third, forth from MyTable) and first,
                    > > and forth have a default of "Default", then do this...
                    > >
                    > > myDatatable.Col umns[0].DefaultValue = "Default";
                    > > myDatatable.Col umns[3].DefaultValue = "Default";
                    > >
                    > > Now when you add a new value you are good to go. Unless I'm
                    > > misunderstandin g, this should solve the problem. Default values don't
                    > > usually change in a db and they're not going to change during a user
                    > > session so setting them at the onset shouldn't be a big deal.
                    > > Moreover, if you were to leave the defaults out, and submit your
                    > > update, they'd be added by the DB when the insert happened and if you
                    > > had the refresh dataset option on or insert logic that refreshed for
                    > > you, the new values would apper in your app. Functionally, there'd be
                    > > little difference. However, if you want the fields in the app to have
                    > > the default value before they go to the db (so the user will see
                    > > exactly what's going to be in the db) , then set the DefaultValue
                    > > property in the column to match its counterpart in the db
                    > >
                    > > I admit though that I may be misunderstandin g so if I am,please let me
                    > > know and I'll do my best.
                    > >
                    > > Cheers,
                    > >
                    > > BIll
                    > >[/color]
                    >
                    > --
                    > Met vriendelijke groet / With regards / Saludos,
                    > Moviat Automatisering
                    >
                    >
                    > Maurice Mertens
                    > mauricem@moviat _KillSpamWordFo rEMail.nl
                    >
                    > tel: +31 162 470 534
                    > fax: +31 162 470 502[/color]


                    Comment

                    • William Ryan  eMVP

                      #11
                      Re: Defaultvalue from database in dataset columns

                      Maurice:

                      I didn't mean to imply that it never changes, but are you saying that the
                      default value or say the LastName column, where a defualt value might be
                      "Not Given" might change to Jones, then to Smith then to Ryan all in say one
                      session?
                      "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
                      news:Xns94D37CC 732D48mauricemm oviat@207.46.24 8.16...[color=blue]
                      > Hi Bill,
                      >
                      > actually I do have a database where the defaultvalue can change. In
                      > Microsoft Access it was possible to change the defaultvalue in the db so
                      > this new defaultvalue would also be the defaultvalue in the application
                      > (Without editing the code in the application).
                      >
                      > But it seems like this isn't possible in .NET.
                      >
                      > In your example when the defaultvalue from column[0] in the database
                      > changes to "NewDefault ", the application will still show "Default" as the
                      > defaultvalue for that column. The next step I have to make is edit the
                      > code in the application (in other words: a version update, I don't want
                      > that).
                      >
                      > thx for helping me out
                      >
                      >
                      >
                      > "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in
                      > news:OLmfmS9JEH A.3216@tk2msftn gp13.phx.gbl:
                      >[color=green]
                      > > I may be confused. You are adding new records locally to a datatable
                      > > and you want the a given default value to appear when you first add a
                      > > new row. For each column that has a default value in the DB, (if your
                      > > query is Select first, second, third, forth from MyTable) and first,
                      > > and forth have a default of "Default", then do this...
                      > >
                      > > myDatatable.Col umns[0].DefaultValue = "Default";
                      > > myDatatable.Col umns[3].DefaultValue = "Default";
                      > >
                      > > Now when you add a new value you are good to go. Unless I'm
                      > > misunderstandin g, this should solve the problem. Default values don't
                      > > usually change in a db and they're not going to change during a user
                      > > session so setting them at the onset shouldn't be a big deal.
                      > > Moreover, if you were to leave the defaults out, and submit your
                      > > update, they'd be added by the DB when the insert happened and if you
                      > > had the refresh dataset option on or insert logic that refreshed for
                      > > you, the new values would apper in your app. Functionally, there'd be
                      > > little difference. However, if you want the fields in the app to have
                      > > the default value before they go to the db (so the user will see
                      > > exactly what's going to be in the db) , then set the DefaultValue
                      > > property in the column to match its counterpart in the db
                      > >
                      > > I admit though that I may be misunderstandin g so if I am,please let me
                      > > know and I'll do my best.
                      > >
                      > > Cheers,
                      > >
                      > > BIll
                      > >[/color]
                      >
                      > --
                      > Met vriendelijke groet / With regards / Saludos,
                      > Moviat Automatisering
                      >
                      >
                      > Maurice Mertens
                      > mauricem@moviat _KillSpamWordFo rEMail.nl
                      >
                      > tel: +31 162 470 534
                      > fax: +31 162 470 502[/color]


                      Comment

                      • Maurice Mertens

                        #12
                        Re: Defaultvalue from database in dataset columns

                        Hi Bill,

                        I didn't understand the answer first untill I read it more thouroughly.
                        You said: "..set the dDefaultValue property in the column to match its
                        counterpart in the db"

                        How do I do that? I know you can set it manual:
                        ds.tables(0).co lumns(0).defaul tvalue = "New York", but what if the
                        defaultvalue in the db changes from "New York" to "L.A.". I will then need
                        to re-edit my code.


                        Can the application find out what the defaultvalue in the db is?


                        Thx!!

                        Comment

                        • Maurice Mertens

                          #13
                          Re: Defaultvalue from database in dataset columns

                          Hi Bill,

                          I didn't understand the answer first untill I read it more thouroughly.
                          You said: "..set the dDefaultValue property in the column to match its
                          counterpart in the db"

                          How do I do that? I know you can set it manual:
                          ds.tables(0).co lumns(0).defaul tvalue = "New York", but what if the
                          defaultvalue in the db changes from "New York" to "L.A.". I will then need
                          to re-edit my code.


                          Can the application find out what the defaultvalue in the db is?


                          Thx!!

                          Comment

                          • William Ryan  eMVP

                            #14
                            Re: Defaultvalue from database in dataset columns

                            AFAIK, you can't grab it from the DB, but what I meant was that you can
                            hard code it. If that won't work, how about this... you could create
                            another table that holds the columname and the default. I understand you
                            have a column who's default changes regularly, but I'm guessing it's only
                            one column or a very few. Regardless. you could query this table when the
                            app starts, then get those values and store them in a class as static
                            properties. Then you could dynamically update this. If it changes more
                            than once in a given user session, then you could even requery in the get
                            accessor of the class so you always have the latest but if they change this
                            much then you probably need a much different solution. Anyway, you can set
                            the default value based on the values in the shared/static class and you'll
                            be good to go.

                            If you don't mind me asking, what drives the situation that requires
                            changing the default value so frequently?

                            ANother thing, you could do is store this in the .config file. Instead of
                            changing it in the db, change it in the app (if the app is the only way the
                            data is accessed, this should be ok, otherwise it's not viable) config file
                            and then your app will handle it.

                            Will this work?
                            "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
                            news:Xns94D393B 969D6mauricemmo viat@207.46.248 .16...[color=blue]
                            > Hi Bill,
                            >
                            > I didn't understand the answer first untill I read it more thouroughly.
                            > You said: "..set the dDefaultValue property in the column to match its
                            > counterpart in the db"
                            >
                            > How do I do that? I know you can set it manual:
                            > ds.tables(0).co lumns(0).defaul tvalue = "New York", but what if the
                            > defaultvalue in the db changes from "New York" to "L.A.". I will then need
                            > to re-edit my code.
                            >
                            >
                            > Can the application find out what the defaultvalue in the db is?
                            >
                            >
                            > Thx!![/color]


                            Comment

                            • William Ryan  eMVP

                              #15
                              Re: Defaultvalue from database in dataset columns

                              AFAIK, you can't grab it from the DB, but what I meant was that you can
                              hard code it. If that won't work, how about this... you could create
                              another table that holds the columname and the default. I understand you
                              have a column who's default changes regularly, but I'm guessing it's only
                              one column or a very few. Regardless. you could query this table when the
                              app starts, then get those values and store them in a class as static
                              properties. Then you could dynamically update this. If it changes more
                              than once in a given user session, then you could even requery in the get
                              accessor of the class so you always have the latest but if they change this
                              much then you probably need a much different solution. Anyway, you can set
                              the default value based on the values in the shared/static class and you'll
                              be good to go.

                              If you don't mind me asking, what drives the situation that requires
                              changing the default value so frequently?

                              ANother thing, you could do is store this in the .config file. Instead of
                              changing it in the db, change it in the app (if the app is the only way the
                              data is accessed, this should be ok, otherwise it's not viable) config file
                              and then your app will handle it.

                              Will this work?
                              "Maurice Mertens" <mauricem@movia t_KillSpamWordF orEMail.nl> wrote in message
                              news:Xns94D393B 969D6mauricemmo viat@207.46.248 .16...[color=blue]
                              > Hi Bill,
                              >
                              > I didn't understand the answer first untill I read it more thouroughly.
                              > You said: "..set the dDefaultValue property in the column to match its
                              > counterpart in the db"
                              >
                              > How do I do that? I know you can set it manual:
                              > ds.tables(0).co lumns(0).defaul tvalue = "New York", but what if the
                              > defaultvalue in the db changes from "New York" to "L.A.". I will then need
                              > to re-edit my code.
                              >
                              >
                              > Can the application find out what the defaultvalue in the db is?
                              >
                              >
                              > Thx!![/color]


                              Comment

                              Working...