PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

copy sql image field to another table

 
 
chris@ctlsoft.com
Guest
Posts: n/a
 
      14th Nov 2005
Hi there, newbie adoneter here. I'm trying to update (or insert) a
record with a sql image field into table 1 based on an existing record
from a similar table (table 2) with vb.net

I used to open recordset use r.edit.....blah... r.update which clearly
can't happen anymore.
so what now ? open 2 sqldatareaders ,save image from table 2 to byte
var, then run 'update' statement on table 1 with sqlcommand ?
Am I on the right track ? tia !

 
Reply With Quote
 
 
 
 
David Sceppa [MSFT]
Guest
Posts: n/a
 
      16th Nov 2005
Chris,

Both the UPDATE and INSERT queries allow you to reference another
table. Your best bet is to construct your UPDATE and INSERT queries so
they copy the image column from the source table to the destination table.
They may look something like:

INSERT INTO DestinationTable
SELECT ... FROM SourceTable
WHERE SourceTable.KeyColumn = ...

UPDATE DestinationTable
SET ImageColumn = SourceTable.ImageColumn
FROM SourceTable
WHERE DestinationTable.KeyColumn = SourceTable.KeyColumn
AND DestinationTable.KeyColumn = ...

I'd recommend trying this approach using Query Analyzer or an ad hoc query
tool until you get the queries just the way you like them.

If the application requires user interaction to determine which rows
to update/insert, you might want to use a SqlDataReader or DataTable to
retrieve the value(s) of the key column(s) and then use that information to
populate parameters on the INSERT or UPDATE query.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2005 Microsoft Corporation. All rights reserved.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy data from one field in a table to a field in another table. =?Utf-8?B?SG93MQ==?= Microsoft Access Form Coding 1 23rd Aug 2007 12:43 PM
Re: automatically copy data from one field to field in same table Brendan Reynolds Microsoft Access Database Table Design 0 20th Sep 2004 04:44 PM
automatically copy data from one field to field in same table =?Utf-8?B?dGFuaWE=?= Microsoft Access Database Table Design 0 20th Sep 2004 04:31 PM
how to show an Image field from a SQL Server table field to a aspx page J Sahoo Microsoft ASP .NET 2 7th Jul 2004 04:10 PM
Copy A Tables Field Data To Another Field In Same Table Chris Moore Microsoft Access Getting Started 5 28th Jul 2003 09:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:55 PM.