Update or insert in adoquery with a join query

Hello Guys,

Sometimes things seem to be easy but they have another face and this is my new dilemma here.

I have a main table in my MS SQL 2000 that has two other joined to it

In my form I have a adoconnection + AdoQuery

This is my query:

SELECT      CADUSO.RH_FUNC_NOME, CADUSO.RH_DEPTO_NOME,
                 CADUSO.RH_EMPRESA_NOME, AGENDA_USO_CONEX.AG_ID,    AGENDA_USO_CONEX.AG_CODUSO
FROM         AGENDA_USO_CONEX
INNER JOIN CADUSO ON AGENDA_USO_CONEX.AG_CODUSO = CADUSO.RH_FUNC_ID

How can I do when I need to change the information? I have an error when I post. Can't I update, insert in Adoquery with
a join query?

Thanks
LVL 1
hidrauAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mokuleCommented:
prepare two independent queries for updating separately each table
0
hidrauAuthor Commented:
Sorry I didn't undertand.

This query I use in my dbgrid, and I make all the changes (insert, edit) in it. How two queries?

Thanks
0
mokuleCommented:
If You are trying to change value in AGENDA_USO_CONEX  table You must execute command something like
UPDATE AGENDA_USO_CONEX SET
and another command for updating
UPDATE CADUSO SET ...

You can't update two tables in one command
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

BlackTigerXCommented:
that's easy, just create a view out of the query that joins the tables, you can then select/insert/update/delete from that view like it was a table, and the changes willl be reflected into the underlying tables
0
BlackTigerXCommented:
or what you might need, is just to include the primary key fields, so the engine can resolve which records you are trying to change

SELECT      CADUSO.RH_FUNC_ID, AGENDA_USO_CONEX.AG_CODUSO
                 CADUSO.RH_FUNC_NOME, CADUSO.RH_DEPTO_NOME,
                 CADUSO.RH_EMPRESA_NOME, AGENDA_USO_CONEX.AG_ID,
FROM         AGENDA_USO_CONEX (nolock)
INNER JOIN CADUSO (nolock) ON AGENDA_USO_CONEX.AG_CODUSO = CADUSO.RH_FUNC_ID

I guess you were just missing CADUSO.RH_FUNC_ID
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hidrauAuthor Commented:
Hello blackTigerX, so I can create a view and update , insert and everything. But a simple query with join is not possible, right????

0
hidrauAuthor Commented:
BlackTigerx, Can I do the same in access table?
0
BlackTigerXCommented:
if you want to be able to update that using a update statement, you can't do it in access, however, if by update you mean like you use the data (that results from running this query) in a DBGrid and you want to be able to make changes there and update the data that way, then you can use this query in any other database (that allows joins)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.