ADO, SQL Server Updating Recordset using 2 Tables 
Author Message
 ADO, SQL Server Updating Recordset using 2 Tables

I have problem by updating recordset using more then one table in the
recordset. There is no problem by updating fields from the first table. I
can set the fields from the second table but by executing the Update method
i have error message :

        Run-time Error '-2147467259 (80004005)
        [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid Column Name
'Stock'

Is there an ADO bug or am I doing something wrong. I try it allready with
ADO 2.5 and had the same problem.

My SQL statment :

SQL = SELECT * FROM Items INNER JOIN Stock on Items.Plu_Code =
Stock.Plu_Code WHERE Descript LIKE 'G%' AND Branch_02 <> 0 AND
Stock.Betrieb=2

I open it with Command

mRS.Open SQL,mConnection,adOpenKeySet,adLockOptimistic,adCmdText

I Open Connection with following command

sConnetstring ="DRIVER=SQL Server;SERVER=NT5SRV-MK;UID=sa;PWD=;APP=Visual
Basic;WSID=NTWS-DAMIR;DATABASE=neXStore;TranslationName=Yes"
mConnection.Open sConnectString

To update recordset I am using the following code

  mRS("Plu_Code") = Product.PluCode    'Field from ItemsTable
  mRS("Descript") = Product.Descript        'Field from Items Table
  mRS("CostPrice_Aktuell")                         'Field from Items Table
  .
  .
  .
  mRS("Stock") = Product.Stock                  'Field from Stock Table
  mRS.Update                                                ' Here I have
Error I mentioned before



Tue, 17 Sep 2002 03:00:00 GMT  
 ADO, SQL Server Updating Recordset using 2 Tables
sql server only allows updating one table in a join in a single
update. a solution would be to write a stored procedure that does two
updates in a transaction, passing it table and column values as
parameters. you can then use an ado command object to call the stored
procedure.

On Fri, 31 Mar 2000 10:56:16 +0200, "Damir Komaric"

Quote:

>I have problem by updating recordset using more then one table in the
>recordset. There is no problem by updating fields from the first table. I
>can set the fields from the second table but by executing the Update method
>i have error message :

>        Run-time Error '-2147467259 (80004005)
>        [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid Column Name
>'Stock'

>Is there an ADO bug or am I doing something wrong. I try it allready with
>ADO 2.5 and had the same problem.

>My SQL statment :

>SQL = SELECT * FROM Items INNER JOIN Stock on Items.Plu_Code =
>Stock.Plu_Code WHERE Descript LIKE 'G%' AND Branch_02 <> 0 AND
>Stock.Betrieb=2

>I open it with Command

>mRS.Open SQL,mConnection,adOpenKeySet,adLockOptimistic,adCmdText

>I Open Connection with following command

>sConnetstring ="DRIVER=SQL Server;SERVER=NT5SRV-MK;UID=sa;PWD=;APP=Visual
>Basic;WSID=NTWS-DAMIR;DATABASE=neXStore;TranslationName=Yes"
>mConnection.Open sConnectString

>To update recordset I am using the following code

>  mRS("Plu_Code") = Product.PluCode    'Field from ItemsTable
>  mRS("Descript") = Product.Descript        'Field from Items Table
>  mRS("CostPrice_Aktuell")                         'Field from Items Table
>  .
>  .
>  .
>  mRS("Stock") = Product.Stock                  'Field from Stock Table
>  mRS.Update                                                ' Here I have
>Error I mentioned before



Tue, 17 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Batch update for multiple tables using single ADO Recordset (VB )

2. Inserting data from an ADO recordset into a SQL Server table

3. Batch update for multiple tables using single ADO Recordset (VB )

4. ADO Data Controls + Using SQL instead of recordset.update

5. Using ado recordset in an SQL Server inner join

6. Link SQL server table to Access using ADO

7. 2nd SQL Server update after update text field corrupts row - using RDO

8. VB6 - CR7 - SQL Server - Want to send either SQL or ADO recordset to report

9. Updating Tables with SQL in VB6 using vfoxpro tables

10. Using RDO to do SQL updates on SQL Server 6.0

11. VB6: Oracle 8/SQL Server 2000 compatibility problems using ADO 2.5 and SQL

12. Oracle multiple table update with one ADO recordset

 

 
Powered by phpBB® Forum Software