[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB6 / ADO / MS Sql Server field name resolution.

Posted on 2000-02-13
8
Medium Priority
?
273 Views
Last Modified: 2013-12-25
Using ADO to connect to MS Sql Server from VB6 we access the names of fields in the following manner.

FieldName = rs.Fields(r&).Name

In our SQL queries we sometimes need to implicitly name the table with the field name especially where joins are concerned see example...

Select Person.FullName, Person.FirstName from Person etc....

The problem is that the table name is not returned in the fieldname as it is with many of the other backend databases that we are familiar with.

Is it possible to get the source table for each field in the recordset?

0
Comment
Question by:finster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 2517422
>get the source table
rs.Fields(1).SourceTable
0
 

Author Comment

by:finster
ID: 2517481
Which version of ADO is that? I cannot find it in the object library, and I know that this functioinality was in DAO and RDO.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2517605
field1 = rs(0).name

to get a value

just simply this

field2 = rs(0)

i don't really understand the question of what you need to be done.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:finster
ID: 2517912
In the sample query:

Select Person.FullName, Person.FirstName from Person

we need an ADO method that will return "Person" when queried. We can already get the FieldName, but we also want the Table Name of where that field came from.
0
 
LVL 15

Expert Comment

by:ameba
ID: 2518503
Sorry, that 'SourceTable' was DAO.
You can check properties collection of your field, e.g.
? rs.fields(1).Properties(1).name
BASETABLENAME

Depending on the provider, that property can have other name.
After checking property name, use something like
? rs.fields(1).Properties("BASETABLENAME").value
0
 

Expert Comment

by:vinoopauls
ID: 2519935
as ameba mentioned

rs.fields(1).Properties(1).name

gives the table name
 
0
 
LVL 15

Accepted Solution

by:
ameba earned 200 total points
ID: 2520840
No, it gives "BASETABLENAME" :)
Use .Value
0
 

Author Comment

by:finster
ID: 2521072
for this method, we found that

rs.fields(1).Properties(3).value

gave us what we wanted

Thanks to all
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question