<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwizguide.com/rss_namespace/">
 <channel>
  <title>Parker Software Forum : Script for inserting binary file data into a db</title>
  <link>http://www.parkersoft.co.uk/forum/</link>
  <description>This is an XML content feed of; Parker Software Forum : Scripting Samples : Script for inserting binary file data into a db</description>
  <pubDate>Wed, 19 Jun 2013 15:19:29 +0000</pubDate>
  <lastBuildDate>Mon, 23 Apr 2012 15:43:55 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.64</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.parkersoft.co.uk/forum/RSS_post_feed.asp?TID=7069</WebWizForums:feedURL>
  <image>
   <title>Parker Software Forum</title>
   <url>http://www.parkersoft.co.uk/forum/forum_images/PSLSmall.bmp</url>
   <link>http://www.parkersoft.co.uk/forum/</link>
  </image>
  <item>
   <title>Script for inserting binary file data into a db :  I am having a problem when i...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=19354#19354</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2796" rel="nofollow">jjaroska</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 23 Apr 2012 at 3:43pm<br /><br />I am having a problem when i read the file inserted into the database. &nbsp;i get the error the magic number is wrong. &nbsp;it seems that this is a common asp.net error message when the whole file is not present. &nbsp;i can write and read other files when i use the file component from devexpress but not when i use the script from this thread. &nbsp;can someone help?<span style="font-size:10px"><br /><br />Edited by jjaroska - 23 Apr 2012 at 3:44pm</span>]]>
   </description>
   <pubDate>Mon, 23 Apr 2012 15:43:55 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=19354#19354</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : We had a problem with the script...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18484#18484</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2604" rel="nofollow">andyj1970</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 27 Jun 2011 at 1:36pm<br /><br />We had a problem with the script running againt Oracle 11g database to load attachments as above. The first attachment loads fine but subsequent ones were not being loaded. The error message shown in the service log was:<DIV>&nbsp;</DIV><DIV><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Verdana','sans-serif'">2011-06-22:12:20:07&nbsp; ## file closed successfully ## <?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Verdana','sans-serif'">2011-06-22:12:20:07 Error in script: ROW-00014: Cannot update row as the data in the database has changedzfPu<o:p></o:p></SPAN></P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Verdana','sans-serif'">2011-06-22:12:20:07 New record added to database</P><DIV></DIV><DIV></DIV><DIV></DIV><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p></o:p>&nbsp;</P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p><FONT size=2>I checked some info online and the script appeared to be fine. I'm not a VB expert but one suggestion was to change the connection from <SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-GB; mso-bidi-font-family: Calibri; mso-ansi-: EN-GB; mso-bidi-: AR-SA">adOpenDynamic to <SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-US; mso-ansi-: EN-GB; mso-bidi-: AR-SA"><strong>adOpenKeyset as below.</strong></SPAN></SPAN></FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p></o:p>&nbsp;</P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-GB; mso-bidi-font-family: Calibri; mso-ansi-: EN-GB; mso-bidi-: AR-SA">&nbsp;&nbsp;&nbsp;&nbsp;cec_contacts.Open "cec_contacts",DBConnection,<SPAN style="FONT-SIZE: 11pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-US; mso-ansi-: EN-GB; mso-bidi-: AR-SA"><strong>adOpenKeyset</strong></SPAN>,adLockOptimistic</SPAN></o:p></P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-GB; mso-bidi-font-family: Calibri; mso-ansi-: EN-GB; mso-bidi-: AR-SA"></SPAN></o:p>&nbsp;</P><P =Ms&#111;normal style="MARGIN: 0cm 0cm 0pt"><o:p><SPAN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: 'Verdana','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-: EN-GB; mso-bidi-font-family: Calibri; mso-ansi-: EN-GB; mso-bidi-: AR-SA">Once we did this the script now processes multiple attachments successfully.</SPAN></o:p></SPAN></P></DIV>]]>
   </description>
   <pubDate>Mon, 27 Jun 2011 13:36:49 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18484#18484</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : Thanks James,This is my script,...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18455#18455</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2598" rel="nofollow">ash0602</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 15 Jun 2011 at 1:45pm<br /><br />Thanks James,<div><br></div><div>This is my script, as mentioned earlier, %msg_uid% is not getting updated in the parent table (but getting updated in the child table). I was doing field extraction, and now even after adding in the script below, the cec_contacts.cnt_msg_uid (my parent table's column for&nbsp;%msg_uid%) is not getting updated. Without which I'll not be able to reference attachments from the parent table. Need help on this:</div><div><br></div><div><div>Sub Main()</div><div>&nbsp;&nbsp; ' this script saves the saved attachment filenames in the Attachment table</div><div>&nbsp;&nbsp; &nbsp;' we have added a reference to the Microsoft ActiveX Data Objects (ADO).</div><div>&nbsp;&nbsp; &nbsp;' it assumes you already have a table called 'cec_contact_attachments' in the database.</div><div><br></div><div>&nbsp;&nbsp; &nbsp;If MSG_AttachmentCount=0 Then Exit Sub ' if no attachments do nothing</div><div><br></div><div>&nbsp;&nbsp; &nbsp;Dim DBConnection As New ADODB.Connection</div><div>&nbsp;&nbsp; &nbsp;' child table</div><div>&nbsp;&nbsp; &nbsp;Dim cec_contact_attachments As New ADODB.Recordset</div><div>&nbsp;&nbsp; &nbsp;' parent table</div><div>&nbsp;&nbsp; &nbsp;Dim cec_contacts As New ADODB.Recordset</div><div>&nbsp;&nbsp; &nbsp;Dim myStream As ADODB.Stream</div><div><br></div><div>&nbsp;&nbsp; &nbsp;Dim A As Integer</div><div><br></div><div>&nbsp;&nbsp; &nbsp;On Error GoTo erl</div><div>&nbsp;&nbsp; &nbsp;DBConnection.ConnectionString="Provider=OraOLEDB.Oracle.1;Password=custemails;Persist Security Info=True;User ID=custemails;Data Source=apexdev;" ' use the connection string specified on the Database tab</div><div>&nbsp;&nbsp; &nbsp;DBConnection.Open</div><div><br></div><div>&nbsp;&nbsp; &nbsp;' open the cec_contacts table</div><div>&nbsp;&nbsp; &nbsp;cec_contacts.Open "cec_contacts",DBConnection,adOpenDynamic,adLockOptimistic</div><div><br></div><div>&nbsp;&nbsp; &nbsp;' update relevant columns</div><div>&nbsp;&nbsp; &nbsp;cec_contacts.Fields("cnt_msg_uid")=MSG_UID</div><div>&nbsp;&nbsp; &nbsp;cec_contacts.Fields("cnt_file_count")=MSG_AttachmentCount</div><div>&nbsp;&nbsp; &nbsp;cec_contacts.Update</div><div><br></div><div>&nbsp;&nbsp; &nbsp;cec_contacts.Close</div><div><br></div><div>&nbsp;&nbsp; &nbsp;' open the cec_contact_attachments table</div><div>&nbsp;&nbsp; &nbsp;cec_contact_attachments.Open "cec_contact_attachments",DBConnection,adOpenDynamic,adLockOptimistic</div><div><br></div><div>&nbsp;&nbsp; &nbsp;For A=1 To MSG_AttachmentCount</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;If len(msg_attachment(A)) &gt; 0&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Then</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AddToLog("Processing: " &amp; MSG_Attachment(A))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.AddNew</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'cec_contact_attachments.Fields("cat_cnt_id")=CNT_ID</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_cnt_msg_uid")=MSG_UID</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_file_sequence")=A</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_file_name")=MSG_Attachment(A)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Set myStream = New ADODB.Stream</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AddToLog("File is type: " &amp; MSG_AttachmentType(A))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;myStream.Type = adTypeBinary</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AddToLog("Opening temp file: " &amp; MSG_AttachmentTempLocation(A))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;myStream.Open</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;myStream.LoadFromFile(MSG_AttachmentTempLocation(A))</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_file_content")=myStream.Read</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_file_size")=myStream.Size</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;myStream.Close</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Fields("cat_file_mime_type")=MSG_AttachmentType(A)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cec_contact_attachments.Update</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;End If</div><div>&nbsp;&nbsp; &nbsp;Next A</div><div><br></div><div>&nbsp;&nbsp; &nbsp;cec_contact_attachments.Close</div><div><br></div><div>&nbsp;&nbsp; &nbsp;DBConnection.Close</div><div><br></div><div>&nbsp;&nbsp; &nbsp;Call AddToLog("cec_contact_attachments table updated successfully")</div><div><br></div><div>&nbsp;&nbsp; &nbsp;Exit Sub</div><div><br></div><div>erl:</div><div>&nbsp;&nbsp; &nbsp;Call AddToLog("Error in script: " &amp; Err.Description)</div><div>End Sub</div></div>]]>
   </description>
   <pubDate>Wed, 15 Jun 2011 13:45:52 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18455#18455</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : The script would be the same,...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18454#18454</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2008" rel="nofollow">James Horton</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 15 Jun 2011 at 1:38pm<br /><br />The script would be the same, just make sure that the Update Database section of the trigger is referencing your database via the Connection String or builder.]]>
   </description>
   <pubDate>Wed, 15 Jun 2011 13:38:33 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18454#18454</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db :  Hi, Can someone help with similar...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18453#18453</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2598" rel="nofollow">ash0602</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 15 Jun 2011 at 10:43am<br /><br /><div>Hi,</div><div><br></div>Can someone help with similar script for Oracle, please?<div>And where should I put this script into?</div><div><br></div><div>Thanks,</div><div>Ashish</div><span style="font-size:10px"><br /><br />Edited by ash0602 - 15 Jun 2011 at 10:45am</span>]]>
   </description>
   <pubDate>Wed, 15 Jun 2011 10:43:58 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=18453#18453</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : That normally means you haven&amp;#039;t...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17429#17429</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1089" rel="nofollow">Daniel</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 10 May 2010 at 9:36am<br /><br />That normally means you haven't added the reference to ADO with the references button at the top of the window;&nbsp; have you done this?]]>
   </description>
   <pubDate>Mon, 10 May 2010 09:36:23 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17429#17429</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : Dim DBConnection As New ADODB.Connection...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17407#17407</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2325" rel="nofollow">iareanet</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 29 Apr 2010 at 7:45pm<br /><br />Dim DBConnection As New ADODB.Connection<BR>&nbsp;&nbsp;&nbsp; Dim Attachments As New ADODB.Recordset<BR>&nbsp;&nbsp;&nbsp; Dim myStream As ADODB.Stream<BR>&nbsp;are giving me an error <DIV></DIV><DIV></DIV>expecting a specific object type]]>
   </description>
   <pubDate>Thu, 29 Apr 2010 19:45:40 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17407#17407</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : Hi Jen (sorry for the delayed...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17132#17132</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1089" rel="nofollow">Daniel</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 18 Feb 2010 at 8:50pm<br /><br />Hi Jen (sorry for the delayed response, I didn't spot this)<DIV>&nbsp;</DIV><DIV>As far as I am aware there aren't any issues with file size - I've definitely done 1MB files before.&nbsp; It could be a setting in the database options that controls this, or a time out?&nbsp; What error code does it give?</DIV>]]>
   </description>
   <pubDate>Thu, 18 Feb 2010 20:50:44 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=17132#17132</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : i&amp;#039;m using a variation on...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16983#16983</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=2028" rel="nofollow">jenik</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 14 Jan 2010 at 7:28pm<br /><br />i'm using a variation on this script to insert an attachment into CRM.&nbsp; but it seems to fail when the attachment is over 200 KB.&nbsp; is there a setting either in Email2DB or on the server that i can do to increase the file size limit?&nbsp; i've added a buffer of 500KB to my code, but it doesn't seem to make a difference:<br><br>myStream.Read(512000)<br><br>thanks,<br>jen<br>]]>
   </description>
   <pubDate>Thu, 14 Jan 2010 19:28:27 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16983#16983</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : For SQL Server you could alsouse:  Attachments.Open...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16262#16262</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=738" rel="nofollow">Stephen</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 19 May 2009 at 1:50pm<br /><br />For SQL Server you could also&nbsp;use:<DIV>&nbsp;</DIV><DIV>&nbsp;Attachments.Open "Attachments",DBConnection,adOpenDynamic,adLockOptimistic,adCmdTableDirect</DIV><DIV>&nbsp;</DIV><DIV>The 'adCmdTableDirect' opens the specified table directly.</DIV><DIV>&nbsp;</DIV><DIV>Steve</DIV>]]>
   </description>
   <pubDate>Tue, 19 May 2009 13:50:02 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16262#16262</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : For MS SQL 2005 the following...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16257#16257</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1596" rel="nofollow">matrixIII</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 17 May 2009 at 4:45pm<br /><br />For MS SQL 2005 the following line as giving an error - something about stored procedure not found. <DIV>&nbsp;Attachments.Open "Attachments",DBConnection,adOpenDynamic,adLockOptimistic<BR></DIV><DIV>&nbsp;</DIV><DIV>I changed it to the following and it started working</DIV><DIV>Attachments.Open "Select * from Attachments where 1=2",DBConnection,adOpenDynamic,adLockOptimistic<BR></DIV><DIV>&nbsp;</DIV><DIV>Thanks.. this article was a great help!</DIV><span style="font-size:10px"><br /><br />Edited by matrixIII - 17 May 2009 at 4:46pm</span>]]>
   </description>
   <pubDate>Sun, 17 May 2009 16:45:59 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=16257#16257</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : Hi Eds,  Thanks for that update!...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15628#15628</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1089" rel="nofollow">Daniel</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 19 Nov 2008 at 11:50am<br /><br />Hi Eds,<br /><br />Thanks for that update!]]>
   </description>
   <pubDate>Wed, 19 Nov 2008 11:50:42 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15628#15628</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : When writing to MySQL 5.1 you...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15620#15620</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1755" rel="nofollow">Eds</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 16 Nov 2008 at 6:26pm<br /><br />When writing to MySQL 5.1 you will need the following or else the binary field will be null.<DIV>&nbsp;</DIV><DIV>&nbsp;DBConnection.CursorLocation = adUseClient<BR>&nbsp;DBConnection.Open<BR></DIV>]]>
   </description>
   <pubDate>Sun, 16 Nov 2008 18:26:57 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15620#15620</guid>
  </item> 
  <item>
   <title>Script for inserting binary file data into a db : Thefollowing script modifies the...</title>
   <link>http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15213#15213</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.parkersoft.co.uk/forum/member_profile.asp?PF=1089" rel="nofollow">Daniel</a><br /><strong>Subject:</strong> 7069<br /><strong>Posted:</strong> 04 Aug 2008 at 2:37pm<br /><br /><DIV>The&nbsp;following script modifies the "Sample" script for "Backup To MS Access &amp; Save Attachments" and saves the data directly to the table.</DIV><DIV>&nbsp;</DIV><DIV>This is the layout of the attachments table:</DIV><DIV>&nbsp;</DIV><DIV><img src="https://www.parkersoft.co.uk/forum/uploads/1089/Image-0012.jpg" height="295" width="549" border="0" /></DIV><DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td><pre class="BBcode">Sub Main()</DIV><DIV>&nbsp;&nbsp; ' this script saves the saved attachment filenames in the Attachment table<BR>&nbsp;&nbsp;&nbsp; ' we have added a reference to the Microsoft ActiveX Data Objects (ADO).<BR>&nbsp;&nbsp;&nbsp; ' it assumes you already have a table called 'Attachments' in the database.</DIV><DIV>&nbsp;&nbsp;&nbsp; If MSG_AttachmentCount=0 Then Exit Sub ' if no attachments do nothing</DIV><DIV>&nbsp;&nbsp;&nbsp; Dim DBConnection As New ADODB.Connection<BR>&nbsp;&nbsp;&nbsp; Dim Attachments As New ADODB.Recordset<BR>&nbsp;&nbsp;&nbsp; Dim myStream As ADODB.Stream</DIV><DIV>&nbsp;&nbsp;&nbsp; Dim A As Integer</DIV><DIV>&nbsp;&nbsp;&nbsp; On Error GoTo erl<BR>&nbsp;&nbsp;&nbsp; DBConnection.ConnectionString=SQL_Connection ' use the connection string specified on the Database tab<BR>&nbsp;&nbsp;&nbsp; DBConnection.Open</DIV><DIV>&nbsp;&nbsp;&nbsp; ' open the Attachments table<BR>&nbsp;&nbsp;&nbsp; Attachments.Open "Attachments",DBConnection,adOpenDynamic,adLockOptimistic<BR>&nbsp;&nbsp;&nbsp; For A=1 To MSG_AttachmentCount</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If len(msg_attachment(A)) &gt; 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; AddToLog("Processing: " &amp; MSG_Attachment(A))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Attachments.AddNew<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;Attachments.Fields("UID")=MSG_UID<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Attachments.Fields("AttachmentNumber")=A<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Attachments.Fields("AttachmentName")=MSG_Attachment(A)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Set myStream = New ADODB.Stream<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; AddToLog("File is type: " &amp; MSG_AttachmentType(A))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; myStream.Type = adTypeBinary<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; AddToLog("Opening temp file: " &amp; MSG_AttachmentTempLocation(A))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; myStream.Open<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; myStream.LoadFromFile(MSG_AttachmentTempLocation(A))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Attachments.Fields("AttachmentData")=myStream.Read<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Attachments.Fields("AttachmentSize")=myStream.Size<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; myStream.Close<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; Attachments.Fields("AttachmentType")=MSG_AttachmentType(A)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Attachments.Update</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Next A</DIV><DIV>&nbsp;&nbsp;&nbsp; Attachments.Close<BR>&nbsp;&nbsp;&nbsp; DBConnection.Close<BR>&nbsp;&nbsp;&nbsp; Call AddToLog("Attachment table updated successfully")<BR>&nbsp;&nbsp;&nbsp; Exit Sub</DIV><DIV>erl:<BR>&nbsp;&nbsp;&nbsp; Call AddToLog("Error in script: " &amp; Err.Description)<BR>End Sub</pre></td></tr></table></DIV><span style="font-size:10px"><br /><br />Edited by Daniel - 28 Jan 2009 at 11:00am</span>]]>
   </description>
   <pubDate>Mon, 04 Aug 2008 14:37:38 +0000</pubDate>
   <guid isPermaLink="true">http://www.parkersoft.co.uk/forum/forum_posts.asp?TID=7069&amp;PID=15213#15213</guid>
  </item> 
 </channel>
</rss>