[quoted text, click to view] Darren Smith wrote:
> I am having a great deal of difficulty accessing individual fields
> generated from a Sql Server 7 view.
>
> When I specify the actual field name, I get the error:
>
> Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
> [Microsoft][ODBC SQL Server Driver][SQL Server]The column prefix
> 'inventory_hardware' does not match with a table name or alias name
> used in the query.
>
>
> The Sql Server 7 view is as follows:
>
> CREATE VIEW [vw_inventory_hardware]
> AS SELECT
> [inventory_hardware].[tag_id],sw_bundle.*, inventory_software.*
This is the first part of your problem right here: using *. To see the
problem: can you tell me what names are being given the two fields that are
both named "sw_bundle_id"? Always provide column aliases so the two fields
in the resultset can be distinguished. This means of course, that you will
need to explicitly specify all the fields you want the view to return. This
will have the added benefit that you will be able to reduce the total number
of columns returned by the view: there is no need to return two columns both
containing the same data is there? And, of course, if you put only one of
the two sw_bundle_id columns in the SELECT list, there will be no need to
use a column alias.
[quoted text, click to view] >
> <%cSql="SELECT inventory_hardware.tag_id from vw_inventory_software"
And here is the second part: Table aliases used in the SELECT list can only
be used if they are defined in the FROM clause. The only data source this
query knows about is vw_inventory_software. It knows nothing about the
tables used to create the view.
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.