473,473 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Accessing multiple tables in a single linked database - error

3 New Member
Hello,


I'm trying to run a query against 3 different tables in a single database on a linked (Access 97 MDB) server.

I'm attempting to run the query through VB.NET code in a Sub, called from a button click.

The query will error out, however, returning for each table (for however many instances of the table name exsist in the query):

Expand|Select|Wrap|Line Numbers
  1. Server: Msg 107, Level 16, State 2, Line 1
  2. The column prefix 'Model' does not match with a table name or alias name used in the query.

code as follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Model.TYPE as TYPE, Model.[MODEL_NO] as [MODEL_NO],
  2.                 Dealer.Dealer_ID, (Dealer.DNAME) AS DName, (Dealer.DADDRESS1)
  3.                 as Address1, (Dealer.DADDRESS2) as Address2, (Dealer.DTOWN)
  4.                 as Town, (Dealer.DContry) as Country, (Dealer.MANAGER)
  5.                 as Manager, Dealer.[TEL (OFFICE)] as OfficeTel, SerialNo.[SERIAL_NO], Model.[MODEL_ID] FROM CoinsTBL...Model
  6.                 INNER JOIN (CoinsTBL...Dealer INNER JOIN CoinsTBL...SerialNo ON
  7.                 Dealer.Dealer_ID = SerialNo.[Dealer_ID]) ON Model.[Model_ID] = SerialNo.[Model_ID]
  8.                 WHERE (((SerialNo.[SERIAL_NO])=6445));
  9.  
I know the code is a mess, I've been fiddling with it for most of the day. I did not write the original code.

I can reduce the number of errors returned by removing table references in front of field names, but that also results in 'ambiguos field name' errors in the JOIN statements.

Any ideas why this won't work? If i strip it down into the component table queries, they all work, but it seems when you add them together, something breaks.
Jan 14 '08 #1
4 1967
code green
1,726 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. The column prefix 'Model' does not match with a table name or alias name used in the query
This error is stating that there is no table with the name Model in your query.
That is you haven't included it in the FROM or as part of a JOIN.
I don't see the need for this prefix
Expand|Select|Wrap|Line Numbers
  1. CoinsTBL...
Jan 15 '08 #2
DOlenchuk
3 New Member
[code]
I don't see the need for this prefix
Expand|Select|Wrap|Line Numbers
  1. CoinsTBL...
that prefix is required for the SQl server to access the linked Access 97 .mdb file.

After more trial-and-error, I managed to get this code to work after prefixing all field names with "COINStbl."

eg: COINStbl.Model.Model_NO

it seems to properly access a linked server, you have to reference it using a full path name.
Jan 15 '08 #3
code green
1,726 Recognized Expert Top Contributor
Now this makes sense
Expand|Select|Wrap|Line Numbers
  1. COINStbl.Model.Model_NO
Database name>>tablename>>fieldname
and is a standard throughout most engines.
I did not recognise the treble '...' but guessed COINStbl was your database.
it seems to properly access a linked server, you have to reference it using a full path name
Surely your connection DB connection command has already established this path?
Jan 15 '08 #4
DOlenchuk
3 New Member
.
Surely your connection DB connection command has already established this path?
This is my Connection code in the VB code behind:

Expand|Select|Wrap|Line Numbers
  1.     ' Make a connection to the SQL Server
  2.     Public Sub dbConnect()
  3.         Try
  4.             sConnectionString = ConfigurationSettings.AppSettings("ConnectionString") ' appSettings in web.config
  5.             connectToCOPSTEST = New SqlConnection(sConnectionString)
  6.  
  7.             If connectToCOPSTEST.State = ConnectionState.Closed Then
  8.                 connectToCOPSTEST.Open()
  9.                 lblConnectionStatus.Text = connectToCOPSTEST.State.ToString
  10.  
  11.             End If
  12.         Catch ex As Exception
  13.             lblMessages.Text = ex.ToString()
  14.         End Try
  15.     End Sub
  16.  
This is the HTML connection string:
Expand|Select|Wrap|Line Numbers
  1. <add key="ConnectionString"
  2.     value="Data Source = ****; User Id=***; Password=***; Database=master; Timeout=200" />
  3.  
It's pointing to the 'master' database, as thats where some stored procedures are for this database project. As far as I could tell, this is nessary due to the linked nature of COINStbl.

Please let me thank you for your help, I'm learning .NET as I go in this project, so its been... Internesting.
Jan 15 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: James Bird | last post by:
Hello In order to perform a hetrogeneous join (I think that's what they're called) between MySQL and another database, I've created an Access database containing linked tables from each...
5
by: Scott Tilton | last post by:
I am having a terrible time getting this to work. I am hoping someone out there can help me with very specific code examples. I am trying to get the linked tables in my Access 97 database to be...
3
by: Tym | last post by:
OK - daft question of the day time... If I have database A which contains all the live data, and Database B which contains linked tables to those is A (i.e. a front end) is there a way of seeing...
6
by: Don Leverton | last post by:
Hi All, I've got a situation where I am developing an Access 97 app for a client, and am in the "beta testing" stage. I have split the app up, using the DB splitter, into front-end /back-end...
11
by: Randy Harris | last post by:
I have been using "IN" to query tables in Oracle from MS Access very successfully. Select Field FROM MyTable IN [ODBC...etc Works great if there is only one table involved. Anyone know how I...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
1
by: James Bird | last post by:
Hello In order to perform a hetrogeneous join (I think that's what they're called) between MySQL and another database, I've created an Access database containing linked tables from each...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
3
by: DeanL | last post by:
Hi guys, Does anyone know of a way to create multiple tables using information stored in one table? I have a table with 4 columns (TableName, ColumnName, DataType, DataSize) and wanted to know...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.