Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

update an inner join statement

Posted on 2014-02-05
10
Medium Priority
?
353 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
[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
  • 4
  • 4
10 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 1500 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 25

Expert Comment

by:chaau
ID: 39837827
Do you have primary keys in your tables?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:al4629740
ID: 39837834
ID in both
0
 
LVL 25

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 25

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 49

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 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