Problem with HOST_NAME Function with Linked View

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

    #1

    Problem with HOST_NAME Function with Linked View

    I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
    with 50,000 records; and I have a selections table with 50,000 records for
    each machine that uses the database (about 25-50). This allows each user to
    have their own set of selections.

    The selections table has three fields: ID (int), Sel (bit), MachName
    (varchar). ID and MachName comprise the primary key.

    I have a view that combines the main table and the entries for the
    selections table for the current machine (SQL below). The view works fine
    when opened in EM and QA. And if I create a pass-through query from my
    Access MDB file, the results are displayed fine.

    However, if I link the view to the Access MDB file, I get "#Deleted" in
    every field of every record (which seems to indicate that the records were
    there and then they were gone). However, if I hard-code the machine name
    into the same view instead of using HOST_NAME and then relink the view to
    the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
    parameter in the view is there a problem with it.

    Anyone have any idea what's going on here, or have heard of any issues with
    HOST_NAME and ODBC linked objects? SQL for the view is below.

    Thanks!

    Neil

    SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
    FROM dbo.INVTRY INNER JOIN
    dbo.InvtrySelec tions ON
    dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
    WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())


  • Sylvain Lafontaine

    #2
    Re: Problem with HOST_NAME Function with Linked View

    First, you shouldn't crosspost to newsgroups not relevant to your problem.

    Second, create a view that will simply select and display the value of
    HOST_NAME() and you will you see if there is a problem with it and
    SQL-Server 7 and a MDB file.

    --
    Sylvain Lafontaine, ing.
    MVP - Technologies Virtual-PC
    E-mail: http://cerbermail.com/?QugbLEWINF


    "Neil" <nospam@nospam. net> wrote in message
    news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...[color=blue]
    >I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
    >with 50,000 records; and I have a selections table with 50,000 records for
    >each machine that uses the database (about 25-50). This allows each user to
    >have their own set of selections.
    >
    > The selections table has three fields: ID (int), Sel (bit), MachName
    > (varchar). ID and MachName comprise the primary key.
    >
    > I have a view that combines the main table and the entries for the
    > selections table for the current machine (SQL below). The view works fine
    > when opened in EM and QA. And if I create a pass-through query from my
    > Access MDB file, the results are displayed fine.
    >
    > However, if I link the view to the Access MDB file, I get "#Deleted" in
    > every field of every record (which seems to indicate that the records were
    > there and then they were gone). However, if I hard-code the machine name
    > into the same view instead of using HOST_NAME and then relink the view to
    > the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
    > parameter in the view is there a problem with it.
    >
    > Anyone have any idea what's going on here, or have heard of any issues
    > with HOST_NAME and ODBC linked objects? SQL for the view is below.
    >
    > Thanks!
    >
    > Neil
    >
    > SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
    > FROM dbo.INVTRY INNER JOIN
    > dbo.InvtrySelec tions ON
    > dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
    > WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
    >[/color]


    Comment

    • Erland Sommarskog

      #3
      Re: Problem with HOST_NAME Function with Linked View

      Neil (nospam@nospam. net) writes:[color=blue]
      > SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
      > FROM dbo.INVTRY INNER JOIN
      > dbo.InvtrySelec tions ON
      > dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
      > WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())[/color]

      Now that I see the entire view, I repeat what I said before: make
      MachName nvarchar, and put the clustered index on this column.


      --
      Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

      Books Online for SQL Server SP3 at
      http://www.microsoft.com/sql/techinf...2000/books.asp

      Comment

      • Trevor Best

        #4
        Re: Problem with HOST_NAME Function with Linked View

        Neil wrote:[color=blue]
        > I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
        > with 50,000 records; and I have a selections table with 50,000 records for
        > each machine that uses the database (about 25-50). This allows each user to
        > have their own set of selections.
        >
        > The selections table has three fields: ID (int), Sel (bit), MachName
        > (varchar). ID and MachName comprise the primary key.
        >
        > I have a view that combines the main table and the entries for the
        > selections table for the current machine (SQL below). The view works fine
        > when opened in EM and QA. And if I create a pass-through query from my
        > Access MDB file, the results are displayed fine.
        >
        > However, if I link the view to the Access MDB file, I get "#Deleted" in
        > every field of every record (which seems to indicate that the records were
        > there and then they were gone). However, if I hard-code the machine name
        > into the same view instead of using HOST_NAME and then relink the view to
        > the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
        > parameter in the view is there a problem with it.
        >
        > Anyone have any idea what's going on here, or have heard of any issues with
        > HOST_NAME and ODBC linked objects? SQL for the view is below.[/color]

        I've not had any problems with Host_name() as a parameter, as the only
        records I retrieve are for my particular machine there is very little
        point in returning that column so I never ask the server for it as I
        know the value already.

        A couple of things you need to know about Access and SQL Server, firstly
        bit fields should be made NOT NULL and default to 0 as Access interprets
        these as Jet Yes/No columns and treats them accordingly so it expects a
        value to be there (In Access/Jet, a Yes/No column cannot be null and
        defaults to 0). The results otherwise can be unpredictable.

        Secondly, if you have any floating point columns in your data (including
        datetime as these are stored as floating point numbers) then you most
        probably need a timestamp column as floating point errors can cause the
        #Deleted condition you describe.

        Comment

        • Guest's Avatar

          #5
          Re: Problem with HOST_NAME Function with Linked View

          Obscure footnote:[color=blue]
          > any floating point columns in your data (including
          > datetime as these are stored as floating point numbers)[/color]

          SQL Server doesn't store datetime as double. Access does,
          and the problem arises because of the rounding error in
          the conversion between the Access version and the SQL
          Server version, even when values are not 'stored' in Access
          at all.

          (david)

          "Trevor Best" <nospam@localho st.invalid> wrote in message
          news:43656dd0$0 $345$da0feed9@n ews.zen.co.uk.. .[color=blue]
          > Neil wrote:[/color]
          ..>[color=blue]
          > I've not had any problems with Host_name() as a parameter, as the only
          > records I retrieve are for my particular machine there is very little
          > point in returning that column so I never ask the server for it as I
          > know the value already.
          >
          > A couple of things you need to know about Access and SQL Server, firstly
          > bit fields should be made NOT NULL and default to 0 as Access interprets
          > these as Jet Yes/No columns and treats them accordingly so it expects a
          > value to be there (In Access/Jet, a Yes/No column cannot be null and
          > defaults to 0). The results otherwise can be unpredictable.
          >
          > Secondly, if you have any floating point columns in your data (including
          > datetime as these are stored as floating point numbers) then you most
          > probably need a timestamp column as floating point errors can cause the
          > #Deleted condition you describe.[/color]


          Comment

          • Neil

            #6
            Re: Problem with HOST_NAME Function with Linked View


            "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
            wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...[color=blue]
            > First, you shouldn't crosspost to newsgroups not relevant to your problem.[/color]

            I wasn't aware that I had done that.
            [color=blue]
            >
            > Second, create a view that will simply select and display the value of
            > HOST_NAME() and you will you see if there is a problem with it and
            > SQL-Server 7 and a MDB file.[/color]

            Good point. I created a view that returned the value of HOST_NAME(), and it
            linked fine into the MDB. I also created a new table, gave it a two-field
            PK, and used HOST_NAME() as a parameter for one of the fields in a view.
            That view also linked and displayed records fine. (Didn't do a two-table
            test, which would be similar to what I'm working with. But it shows that
            HOST_NAME() works fine with MDB linked views.)

            Neil

            [color=blue]
            >
            > --
            > Sylvain Lafontaine, ing.
            > MVP - Technologies Virtual-PC
            > E-mail: http://cerbermail.com/?QugbLEWINF
            >
            >
            > "Neil" <nospam@nospam. net> wrote in message
            > news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...[color=green]
            >>I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
            >>with 50,000 records; and I have a selections table with 50,000 records for
            >>each machine that uses the database (about 25-50). This allows each user
            >>to have their own set of selections.
            >>
            >> The selections table has three fields: ID (int), Sel (bit), MachName
            >> (varchar). ID and MachName comprise the primary key.
            >>
            >> I have a view that combines the main table and the entries for the
            >> selections table for the current machine (SQL below). The view works fine
            >> when opened in EM and QA. And if I create a pass-through query from my
            >> Access MDB file, the results are displayed fine.
            >>
            >> However, if I link the view to the Access MDB file, I get "#Deleted" in
            >> every field of every record (which seems to indicate that the records
            >> were there and then they were gone). However, if I hard-code the machine
            >> name into the same view instead of using HOST_NAME and then relink the
            >> view to the MDB file, the linked view opens fine. Only when I use
            >> HOST_NAME as a parameter in the view is there a problem with it.
            >>
            >> Anyone have any idea what's going on here, or have heard of any issues
            >> with HOST_NAME and ODBC linked objects? SQL for the view is below.
            >>
            >> Thanks!
            >>
            >> Neil
            >>
            >> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
            >> FROM dbo.INVTRY INNER JOIN
            >> dbo.InvtrySelec tions ON
            >> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
            >> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
            >>[/color]
            >
            >[/color]


            Comment

            • Neil

              #7
              Re: Problem with HOST_NAME Function with Linked View

              After I got your note I did go ahead and make MachName nchar, as BOL says
              that HOST_NAME() returns that type, and the sample it showed of storing its
              return value in a table used an nchar(30) field.

              The InvtrySelection s table had the PK (ID/MachName) as the clustered index.
              I created a second index on MachName alone, and it made it the clustered
              index.

              With the above two changes, the results were the same. Still getting
              "#Deleted".

              Neil


              "Erland Sommarskog" <esquel@sommars kog.se> wrote in message
              news:Xns970061F 02065Yazorman@1 27.0.0.1...[color=blue]
              > Neil (nospam@nospam. net) writes:[color=green]
              >> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
              >> FROM dbo.INVTRY INNER JOIN
              >> dbo.InvtrySelec tions ON
              >> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
              >> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())[/color]
              >
              > Now that I see the entire view, I repeat what I said before: make
              > MachName nvarchar, and put the clustered index on this column.
              >
              >
              > --
              > Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se
              >
              > Books Online for SQL Server SP3 at
              > http://www.microsoft.com/sql/techinf...2000/books.asp
              >[/color]


              Comment

              • Neil

                #8
                Re: Problem with HOST_NAME Function with Linked View

                [color=blue]
                > I've not had any problems with Host_name() as a parameter, as the only
                > records I retrieve are for my particular machine there is very little
                > point in returning that column so I never ask the server for it as I know
                > the value already.
                >
                > A couple of things you need to know about Access and SQL Server, firstly
                > bit fields should be made NOT NULL and default to 0 as Access interprets
                > these as Jet Yes/No columns and treats them accordingly so it expects a
                > value to be there (In Access/Jet, a Yes/No column cannot be null and
                > defaults to 0). The results otherwise can be unpredictable.[/color]

                Yes, the bit field is Not Null and defaults to zero.
                [color=blue]
                >
                > Secondly, if you have any floating point columns in your data (including
                > datetime as these are stored as floating point numbers) then you most
                > probably need a timestamp column as floating point errors can cause the
                > #Deleted condition you describe.[/color]

                I don't have any floating point columns in my table. However, I went ahead
                and added a timestamp field anyway. Same results.

                Neil


                Comment

                • Neil

                  #9
                  Re: Problem with HOST_NAME Function with Linked View

                  Hello, everyone.

                  I've made some progress with this strange situation. I played around with
                  different scenarios of the view with HOST_NAME that won't work when linked
                  to the MDB file, removing most fields, trying just one table, then the
                  other, and kept getting the "#Deleted" results. However, I found then when I
                  didn't assign a logical primary key when I linked the view, the results
                  displayed fine!

                  That only makes the situation stranger. But there it is.

                  In another post here I noted that I had created a test table with a
                  two-field PK, one of which contained the HOST_NAME value, and created a view
                  which returned records from this test table, with HOST_NAME() as a parameter
                  for that field. When I linked that view to the MDB file, selecting the two
                  PK fields as the logical primary key, it worked fine. So it's not all
                  logical primary keys that it has problems with.

                  Neil

                  "Neil" <nospam@nospam. net> wrote in message
                  news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...[color=blue]
                  >I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
                  >with 50,000 records; and I have a selections table with 50,000 records for
                  >each machine that uses the database (about 25-50). This allows each user to
                  >have their own set of selections.
                  >
                  > The selections table has three fields: ID (int), Sel (bit), MachName
                  > (varchar). ID and MachName comprise the primary key.
                  >
                  > I have a view that combines the main table and the entries for the
                  > selections table for the current machine (SQL below). The view works fine
                  > when opened in EM and QA. And if I create a pass-through query from my
                  > Access MDB file, the results are displayed fine.
                  >
                  > However, if I link the view to the Access MDB file, I get "#Deleted" in
                  > every field of every record (which seems to indicate that the records were
                  > there and then they were gone). However, if I hard-code the machine name
                  > into the same view instead of using HOST_NAME and then relink the view to
                  > the MDB file, the linked view opens fine. Only when I use HOST_NAME as a
                  > parameter in the view is there a problem with it.
                  >
                  > Anyone have any idea what's going on here, or have heard of any issues
                  > with HOST_NAME and ODBC linked objects? SQL for the view is below.
                  >
                  > Thanks!
                  >
                  > Neil
                  >
                  > SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                  > FROM dbo.INVTRY INNER JOIN
                  > dbo.InvtrySelec tions ON
                  > dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                  > WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                  >[/color]


                  Comment

                  • Sylvain Lafontaine

                    #10
                    Re: Problem with HOST_NAME Function with Linked View

                    One possible cause for seeing things like #deleted is a missing primary key
                    or Access is not able to determine which field is the primary key.

                    You have said in your first post that you have defined a composite primary
                    key on two field. This is quite possibly the source of your problem: you
                    should try replacing it with a single field primary key. From past
                    experience, Access seems to have a lot of trouble with linked tables or
                    views having composite primary keys.

                    Also, take a look at the following article; in case it might help you:


                    --
                    Sylvain Lafontaine, ing.
                    MVP - Technologies Virtual-PC
                    E-mail: http://cerbermail.com/?QugbLEWINF


                    "Neil" <nospam@nospam. net> wrote in message
                    news:hFf9f.3901 $yX2.1657@newsr ead2.news.pas.e arthlink.net...[color=blue]
                    >
                    > "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                    > wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...[color=green]
                    >> First, you shouldn't crosspost to newsgroups not relevant to your
                    >> problem.[/color]
                    >
                    > I wasn't aware that I had done that.
                    >[color=green]
                    >>
                    >> Second, create a view that will simply select and display the value of
                    >> HOST_NAME() and you will you see if there is a problem with it and
                    >> SQL-Server 7 and a MDB file.[/color]
                    >
                    > Good point. I created a view that returned the value of HOST_NAME(), and
                    > it linked fine into the MDB. I also created a new table, gave it a
                    > two-field PK, and used HOST_NAME() as a parameter for one of the fields in
                    > a view. That view also linked and displayed records fine. (Didn't do a
                    > two-table test, which would be similar to what I'm working with. But it
                    > shows that HOST_NAME() works fine with MDB linked views.)
                    >
                    > Neil
                    >
                    >[color=green]
                    >>
                    >> --
                    >> Sylvain Lafontaine, ing.
                    >> MVP - Technologies Virtual-PC
                    >> E-mail: http://cerbermail.com/?QugbLEWINF
                    >>
                    >>
                    >> "Neil" <nospam@nospam. net> wrote in message
                    >> news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...[color=darkred]
                    >>>I have an Access 2000 MDB file with a SQL 7 back end. I have a main table
                    >>>with 50,000 records; and I have a selections table with 50,000 records
                    >>>for each machine that uses the database (about 25-50). This allows each
                    >>>user to have their own set of selections.
                    >>>
                    >>> The selections table has three fields: ID (int), Sel (bit), MachName
                    >>> (varchar). ID and MachName comprise the primary key.
                    >>>
                    >>> I have a view that combines the main table and the entries for the
                    >>> selections table for the current machine (SQL below). The view works
                    >>> fine when opened in EM and QA. And if I create a pass-through query from
                    >>> my Access MDB file, the results are displayed fine.
                    >>>
                    >>> However, if I link the view to the Access MDB file, I get "#Deleted" in
                    >>> every field of every record (which seems to indicate that the records
                    >>> were there and then they were gone). However, if I hard-code the machine
                    >>> name into the same view instead of using HOST_NAME and then relink the
                    >>> view to the MDB file, the linked view opens fine. Only when I use
                    >>> HOST_NAME as a parameter in the view is there a problem with it.
                    >>>
                    >>> Anyone have any idea what's going on here, or have heard of any issues
                    >>> with HOST_NAME and ODBC linked objects? SQL for the view is below.
                    >>>
                    >>> Thanks!
                    >>>
                    >>> Neil
                    >>>
                    >>> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                    >>> FROM dbo.INVTRY INNER JOIN
                    >>> dbo.InvtrySelec tions ON
                    >>> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                    >>> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                    >>>[/color]
                    >>
                    >>[/color]
                    >
                    >[/color]


                    Comment

                    • Sylvain Lafontaine

                      #11
                      Re: Problem with HOST_NAME Function with Linked View

                      Also, if possible, that a look on the SQL-Server with the Profiler or
                      activate the ODBC tracing option. This will give you the possibility of
                      seeing what Access is trying to do.

                      --
                      Sylvain Lafontaine, ing.
                      MVP - Technologies Virtual-PC
                      E-mail: http://cerbermail.com/?QugbLEWINF


                      "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                      wrote in message news:uTA0rGd3FH A.2640@TK2MSFTN GP09.phx.gbl...[color=blue]
                      > One possible cause for seeing things like #deleted is a missing primary
                      > key or Access is not able to determine which field is the primary key.
                      >
                      > You have said in your first post that you have defined a composite primary
                      > key on two field. This is quite possibly the source of your problem: you
                      > should try replacing it with a single field primary key. From past
                      > experience, Access seems to have a lot of trouble with linked tables or
                      > views having composite primary keys.
                      >
                      > Also, take a look at the following article; in case it might help you:
                      > http://support.microsoft.com/kb/q209123/
                      >
                      > --
                      > Sylvain Lafontaine, ing.
                      > MVP - Technologies Virtual-PC
                      > E-mail: http://cerbermail.com/?QugbLEWINF
                      >
                      >
                      > "Neil" <nospam@nospam. net> wrote in message
                      > news:hFf9f.3901 $yX2.1657@newsr ead2.news.pas.e arthlink.net...[color=green]
                      >>
                      >> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                      >> wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...[color=darkred]
                      >>> First, you shouldn't crosspost to newsgroups not relevant to your
                      >>> problem.[/color]
                      >>
                      >> I wasn't aware that I had done that.
                      >>[color=darkred]
                      >>>
                      >>> Second, create a view that will simply select and display the value of
                      >>> HOST_NAME() and you will you see if there is a problem with it and
                      >>> SQL-Server 7 and a MDB file.[/color]
                      >>
                      >> Good point. I created a view that returned the value of HOST_NAME(), and
                      >> it linked fine into the MDB. I also created a new table, gave it a
                      >> two-field PK, and used HOST_NAME() as a parameter for one of the fields
                      >> in a view. That view also linked and displayed records fine. (Didn't do a
                      >> two-table test, which would be similar to what I'm working with. But it
                      >> shows that HOST_NAME() works fine with MDB linked views.)
                      >>
                      >> Neil
                      >>
                      >>[color=darkred]
                      >>>
                      >>> --
                      >>> Sylvain Lafontaine, ing.
                      >>> MVP - Technologies Virtual-PC
                      >>> E-mail: http://cerbermail.com/?QugbLEWINF
                      >>>
                      >>>
                      >>> "Neil" <nospam@nospam. net> wrote in message
                      >>> news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...
                      >>>>I have an Access 2000 MDB file with a SQL 7 back end. I have a main
                      >>>>table with 50,000 records; and I have a selections table with 50,000
                      >>>>records for each machine that uses the database (about 25-50). This
                      >>>>allows each user to have their own set of selections.
                      >>>>
                      >>>> The selections table has three fields: ID (int), Sel (bit), MachName
                      >>>> (varchar). ID and MachName comprise the primary key.
                      >>>>
                      >>>> I have a view that combines the main table and the entries for the
                      >>>> selections table for the current machine (SQL below). The view works
                      >>>> fine when opened in EM and QA. And if I create a pass-through query
                      >>>> from my Access MDB file, the results are displayed fine.
                      >>>>
                      >>>> However, if I link the view to the Access MDB file, I get "#Deleted" in
                      >>>> every field of every record (which seems to indicate that the records
                      >>>> were there and then they were gone). However, if I hard-code the
                      >>>> machine name into the same view instead of using HOST_NAME and then
                      >>>> relink the view to the MDB file, the linked view opens fine. Only when
                      >>>> I use HOST_NAME as a parameter in the view is there a problem with it.
                      >>>>
                      >>>> Anyone have any idea what's going on here, or have heard of any issues
                      >>>> with HOST_NAME and ODBC linked objects? SQL for the view is below.
                      >>>>
                      >>>> Thanks!
                      >>>>
                      >>>> Neil
                      >>>>
                      >>>> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                      >>>> FROM dbo.INVTRY INNER JOIN
                      >>>> dbo.InvtrySelec tions ON
                      >>>> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                      >>>> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                      >>>>
                      >>>
                      >>>[/color]
                      >>
                      >>[/color]
                      >
                      >[/color]


                      Comment

                      • Neil

                        #12
                        Re: Problem with HOST_NAME Function with Linked View

                        Re. the composite primary key, note that in my test I did create a table
                        with a composite primary key, to simulate the situation, and it worked fine.
                        I followed up on that in my more recent post in this thread, which shows
                        that the situation is now even more bizarre.

                        Regarding changing to a single field primary key, I do not believe that is
                        possible. The main table has a single-field primary key (int, identity), and
                        the other table (which has a one-to-one relationship with the main table)
                        has a dual primary key -- one field corresponding to the main table's
                        primary key, and the other containing the machine name. That table has to
                        have both fields in the primary key.

                        The resulting view can have a one-field or two-field virtual primary key
                        when linked in access, depending on whether or not I include the machine
                        name field in the resultset. Seems to me that it's better to include it and
                        have a two-field primary key, so that Access can determine the record.

                        Neil


                        "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                        wrote in message news:uTA0rGd3FH A.2640@TK2MSFTN GP09.phx.gbl...[color=blue]
                        > One possible cause for seeing things like #deleted is a missing primary
                        > key or Access is not able to determine which field is the primary key.
                        >
                        > You have said in your first post that you have defined a composite primary
                        > key on two field. This is quite possibly the source of your problem: you
                        > should try replacing it with a single field primary key. From past
                        > experience, Access seems to have a lot of trouble with linked tables or
                        > views having composite primary keys.
                        >
                        > Also, take a look at the following article; in case it might help you:
                        > http://support.microsoft.com/kb/q209123/
                        >
                        > --
                        > Sylvain Lafontaine, ing.
                        > MVP - Technologies Virtual-PC
                        > E-mail: http://cerbermail.com/?QugbLEWINF
                        >
                        >
                        > "Neil" <nospam@nospam. net> wrote in message
                        > news:hFf9f.3901 $yX2.1657@newsr ead2.news.pas.e arthlink.net...[color=green]
                        >>
                        >> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                        >> wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...[color=darkred]
                        >>> First, you shouldn't crosspost to newsgroups not relevant to your
                        >>> problem.[/color]
                        >>
                        >> I wasn't aware that I had done that.
                        >>[color=darkred]
                        >>>
                        >>> Second, create a view that will simply select and display the value of
                        >>> HOST_NAME() and you will you see if there is a problem with it and
                        >>> SQL-Server 7 and a MDB file.[/color]
                        >>
                        >> Good point. I created a view that returned the value of HOST_NAME(), and
                        >> it linked fine into the MDB. I also created a new table, gave it a
                        >> two-field PK, and used HOST_NAME() as a parameter for one of the fields
                        >> in a view. That view also linked and displayed records fine. (Didn't do a
                        >> two-table test, which would be similar to what I'm working with. But it
                        >> shows that HOST_NAME() works fine with MDB linked views.)
                        >>
                        >> Neil
                        >>
                        >>[color=darkred]
                        >>>
                        >>> --
                        >>> Sylvain Lafontaine, ing.
                        >>> MVP - Technologies Virtual-PC
                        >>> E-mail: http://cerbermail.com/?QugbLEWINF
                        >>>
                        >>>
                        >>> "Neil" <nospam@nospam. net> wrote in message
                        >>> news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...
                        >>>>I have an Access 2000 MDB file with a SQL 7 back end. I have a main
                        >>>>table with 50,000 records; and I have a selections table with 50,000
                        >>>>records for each machine that uses the database (about 25-50). This
                        >>>>allows each user to have their own set of selections.
                        >>>>
                        >>>> The selections table has three fields: ID (int), Sel (bit), MachName
                        >>>> (varchar). ID and MachName comprise the primary key.
                        >>>>
                        >>>> I have a view that combines the main table and the entries for the
                        >>>> selections table for the current machine (SQL below). The view works
                        >>>> fine when opened in EM and QA. And if I create a pass-through query
                        >>>> from my Access MDB file, the results are displayed fine.
                        >>>>
                        >>>> However, if I link the view to the Access MDB file, I get "#Deleted" in
                        >>>> every field of every record (which seems to indicate that the records
                        >>>> were there and then they were gone). However, if I hard-code the
                        >>>> machine name into the same view instead of using HOST_NAME and then
                        >>>> relink the view to the MDB file, the linked view opens fine. Only when
                        >>>> I use HOST_NAME as a parameter in the view is there a problem with it.
                        >>>>
                        >>>> Anyone have any idea what's going on here, or have heard of any issues
                        >>>> with HOST_NAME and ODBC linked objects? SQL for the view is below.
                        >>>>
                        >>>> Thanks!
                        >>>>
                        >>>> Neil
                        >>>>
                        >>>> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                        >>>> FROM dbo.INVTRY INNER JOIN
                        >>>> dbo.InvtrySelec tions ON
                        >>>> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                        >>>> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                        >>>>
                        >>>
                        >>>[/color]
                        >>
                        >>[/color]
                        >
                        >[/color]


                        Comment

                        • Neil

                          #13
                          Re: Problem with HOST_NAME Function with Linked View

                          ODBC tracing might show something. Now sure what Profiler would yield, since
                          SQL Server seems to be returning the records without any problem.

                          Neil

                          "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                          wrote in message news:%23sye%23I d3FHA.4076@TK2M SFTNGP15.phx.gb l...[color=blue]
                          > Also, if possible, that a look on the SQL-Server with the Profiler or
                          > activate the ODBC tracing option. This will give you the possibility of
                          > seeing what Access is trying to do.
                          >
                          > --
                          > Sylvain Lafontaine, ing.
                          > MVP - Technologies Virtual-PC
                          > E-mail: http://cerbermail.com/?QugbLEWINF
                          >
                          >
                          > "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                          > wrote in message news:uTA0rGd3FH A.2640@TK2MSFTN GP09.phx.gbl...[color=green]
                          >> One possible cause for seeing things like #deleted is a missing primary
                          >> key or Access is not able to determine which field is the primary key.
                          >>
                          >> You have said in your first post that you have defined a composite
                          >> primary key on two field. This is quite possibly the source of your
                          >> problem: you should try replacing it with a single field primary key.
                          >> From past experience, Access seems to have a lot of trouble with linked
                          >> tables or views having composite primary keys.
                          >>
                          >> Also, take a look at the following article; in case it might help you:
                          >> http://support.microsoft.com/kb/q209123/
                          >>
                          >> --
                          >> Sylvain Lafontaine, ing.
                          >> MVP - Technologies Virtual-PC
                          >> E-mail: http://cerbermail.com/?QugbLEWINF
                          >>
                          >>
                          >> "Neil" <nospam@nospam. net> wrote in message
                          >> news:hFf9f.3901 $yX2.1657@newsr ead2.news.pas.e arthlink.net...[color=darkred]
                          >>>
                          >>> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                          >>> wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...
                          >>>> First, you shouldn't crosspost to newsgroups not relevant to your
                          >>>> problem.
                          >>>
                          >>> I wasn't aware that I had done that.
                          >>>
                          >>>>
                          >>>> Second, create a view that will simply select and display the value of
                          >>>> HOST_NAME() and you will you see if there is a problem with it and
                          >>>> SQL-Server 7 and a MDB file.
                          >>>
                          >>> Good point. I created a view that returned the value of HOST_NAME(), and
                          >>> it linked fine into the MDB. I also created a new table, gave it a
                          >>> two-field PK, and used HOST_NAME() as a parameter for one of the fields
                          >>> in a view. That view also linked and displayed records fine. (Didn't do
                          >>> a two-table test, which would be similar to what I'm working with. But
                          >>> it shows that HOST_NAME() works fine with MDB linked views.)
                          >>>
                          >>> Neil
                          >>>
                          >>>
                          >>>>
                          >>>> --
                          >>>> Sylvain Lafontaine, ing.
                          >>>> MVP - Technologies Virtual-PC
                          >>>> E-mail: http://cerbermail.com/?QugbLEWINF
                          >>>>
                          >>>>
                          >>>> "Neil" <nospam@nospam. net> wrote in message
                          >>>> news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...
                          >>>>>I have an Access 2000 MDB file with a SQL 7 back end. I have a main
                          >>>>>table with 50,000 records; and I have a selections table with 50,000
                          >>>>>records for each machine that uses the database (about 25-50). This
                          >>>>>allows each user to have their own set of selections.
                          >>>>>
                          >>>>> The selections table has three fields: ID (int), Sel (bit), MachName
                          >>>>> (varchar). ID and MachName comprise the primary key.
                          >>>>>
                          >>>>> I have a view that combines the main table and the entries for the
                          >>>>> selections table for the current machine (SQL below). The view works
                          >>>>> fine when opened in EM and QA. And if I create a pass-through query
                          >>>>> from my Access MDB file, the results are displayed fine.
                          >>>>>
                          >>>>> However, if I link the view to the Access MDB file, I get "#Deleted"
                          >>>>> in every field of every record (which seems to indicate that the
                          >>>>> records were there and then they were gone). However, if I hard-code
                          >>>>> the machine name into the same view instead of using HOST_NAME and
                          >>>>> then relink the view to the MDB file, the linked view opens fine. Only
                          >>>>> when I use HOST_NAME as a parameter in the view is there a problem
                          >>>>> with it.
                          >>>>>
                          >>>>> Anyone have any idea what's going on here, or have heard of any issues
                          >>>>> with HOST_NAME and ODBC linked objects? SQL for the view is below.
                          >>>>>
                          >>>>> Thanks!
                          >>>>>
                          >>>>> Neil
                          >>>>>
                          >>>>> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                          >>>>> FROM dbo.INVTRY INNER JOIN
                          >>>>> dbo.InvtrySelec tions ON
                          >>>>> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                          >>>>> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                          >>>>>
                          >>>>
                          >>>>
                          >>>
                          >>>[/color]
                          >>
                          >>[/color]
                          >
                          >[/color]


                          Comment

                          • Sylvain Lafontaine

                            #14
                            Re: Problem with HOST_NAME Function with Linked View

                            It is not a requirement for relationships to be based on primary keys; so
                            nothing forbid you to a add a new field as the primary key for the other
                            table and keep the two other fields for your relationship.

                            Using a machine name as part of an index is also a bad idea: you should
                            create another table, put these machine names there and use their identity
                            values for the second table.

                            --
                            Sylvain Lafontaine, ing.
                            MVP - Technologies Virtual-PC
                            E-mail: http://cerbermail.com/?QugbLEWINF


                            "Neil" <nospam@nospam. net> wrote in message
                            news:U7h9f.1895 $8c5.1662@newsr ead3.news.pas.e arthlink.net...[color=blue]
                            > Re. the composite primary key, note that in my test I did create a table
                            > with a composite primary key, to simulate the situation, and it worked
                            > fine. I followed up on that in my more recent post in this thread, which
                            > shows that the situation is now even more bizarre.
                            >
                            > Regarding changing to a single field primary key, I do not believe that is
                            > possible. The main table has a single-field primary key (int, identity),
                            > and the other table (which has a one-to-one relationship with the main
                            > table) has a dual primary key -- one field corresponding to the main
                            > table's primary key, and the other containing the machine name. That table
                            > has to have both fields in the primary key.
                            >
                            > The resulting view can have a one-field or two-field virtual primary key
                            > when linked in access, depending on whether or not I include the machine
                            > name field in the resultset. Seems to me that it's better to include it
                            > and have a two-field primary key, so that Access can determine the record.
                            >
                            > Neil
                            >
                            >
                            > "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                            > wrote in message news:uTA0rGd3FH A.2640@TK2MSFTN GP09.phx.gbl...[color=green]
                            >> One possible cause for seeing things like #deleted is a missing primary
                            >> key or Access is not able to determine which field is the primary key.
                            >>
                            >> You have said in your first post that you have defined a composite
                            >> primary key on two field. This is quite possibly the source of your
                            >> problem: you should try replacing it with a single field primary key.
                            >> From past experience, Access seems to have a lot of trouble with linked
                            >> tables or views having composite primary keys.
                            >>
                            >> Also, take a look at the following article; in case it might help you:
                            >> http://support.microsoft.com/kb/q209123/
                            >>
                            >> --
                            >> Sylvain Lafontaine, ing.
                            >> MVP - Technologies Virtual-PC
                            >> E-mail: http://cerbermail.com/?QugbLEWINF
                            >>
                            >>
                            >> "Neil" <nospam@nospam. net> wrote in message
                            >> news:hFf9f.3901 $yX2.1657@newsr ead2.news.pas.e arthlink.net...[color=darkred]
                            >>>
                            >>> "Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
                            >>> wrote in message news:uQV0$Ra3FH A.2432@TK2MSFTN GP10.phx.gbl...
                            >>>> First, you shouldn't crosspost to newsgroups not relevant to your
                            >>>> problem.
                            >>>
                            >>> I wasn't aware that I had done that.
                            >>>
                            >>>>
                            >>>> Second, create a view that will simply select and display the value of
                            >>>> HOST_NAME() and you will you see if there is a problem with it and
                            >>>> SQL-Server 7 and a MDB file.
                            >>>
                            >>> Good point. I created a view that returned the value of HOST_NAME(), and
                            >>> it linked fine into the MDB. I also created a new table, gave it a
                            >>> two-field PK, and used HOST_NAME() as a parameter for one of the fields
                            >>> in a view. That view also linked and displayed records fine. (Didn't do
                            >>> a two-table test, which would be similar to what I'm working with. But
                            >>> it shows that HOST_NAME() works fine with MDB linked views.)
                            >>>
                            >>> Neil
                            >>>
                            >>>
                            >>>>
                            >>>> --
                            >>>> Sylvain Lafontaine, ing.
                            >>>> MVP - Technologies Virtual-PC
                            >>>> E-mail: http://cerbermail.com/?QugbLEWINF
                            >>>>
                            >>>>
                            >>>> "Neil" <nospam@nospam. net> wrote in message
                            >>>> news:lra9f.1731 $8c5.1137@newsr ead3.news.pas.e arthlink.net...
                            >>>>>I have an Access 2000 MDB file with a SQL 7 back end. I have a main
                            >>>>>table with 50,000 records; and I have a selections table with 50,000
                            >>>>>records for each machine that uses the database (about 25-50). This
                            >>>>>allows each user to have their own set of selections.
                            >>>>>
                            >>>>> The selections table has three fields: ID (int), Sel (bit), MachName
                            >>>>> (varchar). ID and MachName comprise the primary key.
                            >>>>>
                            >>>>> I have a view that combines the main table and the entries for the
                            >>>>> selections table for the current machine (SQL below). The view works
                            >>>>> fine when opened in EM and QA. And if I create a pass-through query
                            >>>>> from my Access MDB file, the results are displayed fine.
                            >>>>>
                            >>>>> However, if I link the view to the Access MDB file, I get "#Deleted"
                            >>>>> in every field of every record (which seems to indicate that the
                            >>>>> records were there and then they were gone). However, if I hard-code
                            >>>>> the machine name into the same view instead of using HOST_NAME and
                            >>>>> then relink the view to the MDB file, the linked view opens fine. Only
                            >>>>> when I use HOST_NAME as a parameter in the view is there a problem
                            >>>>> with it.
                            >>>>>
                            >>>>> Anyone have any idea what's going on here, or have heard of any issues
                            >>>>> with HOST_NAME and ODBC linked objects? SQL for the view is below.
                            >>>>>
                            >>>>> Thanks!
                            >>>>>
                            >>>>> Neil
                            >>>>>
                            >>>>> SELECT INVTRY.*, InvtrySelection s.Sel, InvtrySelection s.MachName
                            >>>>> FROM dbo.INVTRY INNER JOIN
                            >>>>> dbo.InvtrySelec tions ON
                            >>>>> dbo.INVTRY.ID = dbo.InvtrySelec tions.ID
                            >>>>> WHERE (dbo.InvtrySele ctions.MachName = HOST_NAME())
                            >>>>>
                            >>>>
                            >>>>
                            >>>
                            >>>[/color]
                            >>
                            >>[/color]
                            >
                            >[/color]


                            Comment

                            • Trevor Best

                              #15
                              Re: Problem with HOST_NAME Function with Linked View

                              david@epsomdotc omdotau wrote:[color=blue]
                              > Obscure footnote:
                              >[color=green]
                              >>any floating point columns in your data (including
                              >>datetime as these are stored as floating point numbers)[/color]
                              >
                              >
                              > SQL Server doesn't store datetime as double. Access does,
                              > and the problem arises because of the rounding error in
                              > the conversion between the Access version and the SQL
                              > Server version, even when values are not 'stored' in Access
                              > at all.[/color]

                              Sorry, my bad. It's 2 ints (or Longs in AccessSpeak).

                              Comment

                              Working...