![]() |
Script for inserting binary file data into a db |
Post Reply
|
Page 12> |
| Author | |
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Topic: Script for inserting binary file data into a dbPosted: 04 Aug 2008 at 2:37pm |
|
The following script modifies the "Sample" script for "Backup To MS Access & Save Attachments" and saves the data directly to the table.
This is the layout of the attachments table:
![]()
Edited by Daniel - 28 Jan 2009 at 11:00am |
|
|
Daniel Tallentire
Support Parker Software |
|
![]() |
|
Eds
New User
Joined: 12 Nov 2008 Location: United States Posts: 3 |
Post Options
Quote Reply
Posted: 16 Nov 2008 at 6:26pm |
|
When writing to MySQL 5.1 you will need the following or else the binary field will be null.
DBConnection.CursorLocation = adUseClient
DBConnection.Open |
|
![]() |
|
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 19 Nov 2008 at 11:50am |
|
Hi Eds,
Thanks for that update! |
|
|
Daniel Tallentire
Support Parker Software |
|
![]() |
|
matrixIII
Professional
Joined: 21 Jul 2008 Posts: 68 |
Post Options
Quote Reply
Posted: 17 May 2009 at 4:45pm |
|
For MS SQL 2005 the following line as giving an error - something about stored procedure not found.
Attachments.Open "Attachments",DBConnection,adOpenDynamic,adLockOptimistic
I changed it to the following and it started working
Attachments.Open "Select * from Attachments where 1=2",DBConnection,adOpenDynamic,adLockOptimistic
Thanks.. this article was a great help! Edited by matrixIII - 17 May 2009 at 4:46pm |
|
![]() |
|
Stephen
Admin Group
Joined: 21 Oct 2005 Location: Stoke on Trent Posts: 1389 |
Post Options
Quote Reply
Posted: 19 May 2009 at 1:50pm |
|
For SQL Server you could also use:
Attachments.Open "Attachments",DBConnection,adOpenDynamic,adLockOptimistic,adCmdTableDirect
The 'adCmdTableDirect' opens the specified table directly.
Steve
|
|
![]() |
|
jenik
New User
Joined: 15 Jun 2009 Location: San Jose, CA Posts: 2 |
Post Options
Quote Reply
Posted: 14 Jan 2010 at 7:28pm |
|
i'm using a variation on this script to insert an attachment into CRM. but it seems to fail when the attachment is over 200 KB. is there a setting either in Email2DB or on the server that i can do to increase the file size limit? i've added a buffer of 500KB to my code, but it doesn't seem to make a difference:
myStream.Read(512000) thanks, jen |
|
![]() |
|
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 18 Feb 2010 at 8:50pm |
|
Hi Jen (sorry for the delayed response, I didn't spot this)
As far as I am aware there aren't any issues with file size - I've definitely done 1MB files before. It could be a setting in the database options that controls this, or a time out? What error code does it give?
|
|
|
Daniel Tallentire
Support Parker Software |
|
![]() |
|
iareanet
New User
Joined: 28 Apr 2010 Posts: 3 |
Post Options
Quote Reply
Posted: 29 Apr 2010 at 7:45pm |
|
Dim DBConnection As New ADODB.Connection
Dim Attachments As New ADODB.Recordset Dim myStream As ADODB.Stream are giving me an error expecting a specific object type |
|
![]() |
|
Daniel
Admin Group
Technical Director Joined: 19 Dec 2006 Location: Stoke-on-Trent Posts: 875 |
Post Options
Quote Reply
Posted: 10 May 2010 at 9:36am |
|
That normally means you haven't added the reference to ADO with the references button at the top of the window; have you done this?
|
|
|
Daniel Tallentire
Support Parker Software |
|
![]() |
|
ash0602
New User
Joined: 14 Jun 2011 Location: United Kingdom Posts: 2 |
Post Options
Quote Reply
Posted: 15 Jun 2011 at 10:43am |
|
Hi, And where should I put this script into? Thanks, Ashish
Edited by ash0602 - 15 Jun 2011 at 10:45am |
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |