Solved

update an inner join statement

Posted on 2014-02-05
10
339 Views
Last Modified: 2014-03-19
have a datagrid in vb6.  I performed an inner join statement in sql to retreive a recordset from our SQL DB.  When I try to edit the record in the datagrid, I get the following error:

Insufficient key column information for updating or refreshing.

Shouldn't I be able to update an inner join statement?
0
Comment
Question by:al4629740
  • 4
  • 4
10 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39837813
You can update inner joined queries. All you need to do is to make sure that columns that make the primary key of the table to be updated are included into the select statement. Imagine this situation:
Table1: Primary key Column1, Column2, Columns3
Table2: Primary key Column1
SELECT Table1.Column1, Table1.Column2, Table2.Column1
FROM Table1 INNER JOIN Table2 ON Table1.Column1 = Table2.Column1

Open in new window

The above statement will not be converted to the update statement for Table1, as Table1.Column3 is not included into the SELECT clause. Modify the statement like this:
SELECT Table1.Column1, Table1.Column2, Table2.Column1, Table1.Column3
FROM Table1 INNER JOIN Table2 ON Table1.Column1 = Table2.Column1

Open in new window

0
 

Author Comment

by:al4629740
ID: 39837823
This is what I had.  Wouldn't that include it?
select * from tblYAT1 Y1 Inner Join tblYAT2 Y2 on Y1.ID = Y2.ID where Y1.Committee = 'Group1' And Y1.Fiscal = 2014 order by Month, [Last Name]

Open in new window

0
 
LVL 24

Expert Comment

by:chaau
ID: 39837827
Do you have primary keys in your tables?
0
 

Author Comment

by:al4629740
ID: 39837834
ID in both
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 24

Expert Comment

by:chaau
ID: 39837836
Are you including the ID of the updatable table into the datagrid?
0
 

Author Comment

by:al4629740
ID: 39837849
I have what I stated above.

Doesn't the * include it?
0
 
LVL 24

Expert Comment

by:chaau
ID: 39837851
I thought this was an underlying query. I meant: include the column into your datagrid in VB6
0
 

Author Comment

by:al4629740
ID: 39884538
So I can't use *
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39940431
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now