SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-04-2006, 05:27 AM
Virginia SEO's Avatar
Virginia SEO Virginia SEO is offline
SEO Junior and a half
 
Join Date: Jul 2004
Location: Sneads Ferry North Carolina USA
Posts: 46 Virginia SEO is on a distinguished road
Red face Transferring blob from One MSSQL Database to Another

I have the current need to move MS SQL Server 2005 data from an external server to a local host (e.g. shared) windows server. The environment is PHP and I do have the connections created for both external and internal databases.

The question is how to transfer the blob to the local MS Sql Server database from the external MS Sql Server database. I am already able to process all the other fields within the database except the image (e.g. blob) field.

The Ole header data is within the file. Anyone know how to do this?


Example code selecting the data below:

// Specify the login info here. (later move to external file)
// Select from database first
$msserver = '999.99.999.999';
$usrname = 'myusername';
$passwrd = 'mypassword';
$database = 'mydatabase';
$table = 'mytable';
// Build SQL statement here that has the blob field (medium_photo)
// medium_photo is a jpg file 320 x 208
$sql = 'SELECT TOP 100 id, medium_photo FROM ' . $table;

// Open the MS Sql Server Connection
$result = opensqldata($msserver,$usrname,$passwrd,$database, $sql);

// $result declared global within opensqldata function
$nrows = mssql_num_rows($result);


function opensqldata($msserver,$usrname,$passwrd,$database, $sql) {

global $msserver, $usrname, $passwrd, $database, $sql, $result, $dbcon;
// Open the MS Sql Server Connection
$dbcon = mssql_connect($msserver,$usrname,$passwrd);
if ($dbcon) {
echo "<font color='blue'>Connection to $msserver was successful.</font><hr>";
} else {
echo "<font color='red'>Error: ".mssql_get_last_message()."</font><hr>";
} // End if ($dbcon)

// Specify database here
mssql_select_db($database);

// Build SQL statement here
// $sql = 'SELECT TOP 10 * FROM ' . $sel_table;
$result = mssql_query($sql);
return $result;

} // End function open-sql-data
__________________
~ Mike
Antiques Online News::Seafood Recipes
Reply With Quote
  #2  
Old 08-09-2006, 06:55 PM
Virginia SEO's Avatar
Virginia SEO Virginia SEO is offline
SEO Junior and a half
 
Join Date: Jul 2004
Location: Sneads Ferry North Carolina USA
Posts: 46 Virginia SEO is on a distinguished road
Alas, thanks to others on the web forums I have the answer! Converting the data connection to Adodb and converting with the following function, I have been able to sql insert the data from the external MS Sql Server to the local MS Sql Server. Thanks to all who assisted in any manner.

function storeimage($fldimage) {
// Handling IMAGE - BLOB fields
$imgdata = unpack("H*hex", $fldimage);
$imgdataresult = "0x".$imgdata['hex'];

return $imgdataresult;

} // END function storeimage($fldimage) {
__________________
~ Mike
Antiques Online News::Seafood Recipes
Reply With Quote
  #3  
Old 08-10-2006, 09:58 AM
Paz's Avatar
Paz Paz is offline
SEO GUY Moderator
 
Join Date: Sep 2004
Location: Antalya, Turkey
Posts: 4,111 Paz has a spectacular aura aboutPaz has a spectacular aura about
Glad you sorted it out and thanks for taking the time to post a solution. Maybe one day someone will do a search and come across it.

Cheers,
Paz.
__________________
10.3 million entries for Hotels in Turkey but I'm still chipping away.
Reply With Quote
Reply


Thread Tools
Display Modes 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 08:55 PM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.