Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
In their infintite wisdom, Microsoft decided to make Memo fields like Blobs but with some additional bits and bobs on top.

What this means is that you have to connect to the database in a totally different way. This is not a fault of the DBI or Perl as it catches you out in ASP code just as easily. To solve this, as far as I can see, you should use Win32::OLE and build recordsets to access your data. If not, then you'll have to save your data to disk and reference the filename in the database.

If you want the memo fields, the code (in VBScript) is as follows:
Set RS = Server.CreateObject("ADODB.RecordSet") RS.CursorLocation = adUseClient RS.Open table_name_or_sql_query, your_connection_object, adOpenKeyset

I took that from here. Now looking at the constants stuff, we need to define adUseClient and keyset which we can set as :
use constant adUseClient => 3; use constant adOpenKeyset => 1;


So all we need to do now is create the recordset and the connection object. Full code
use Win32::OLE; use strict; use constant adUseClient => 3; use constant adOpenKeySet => 1; my $db_connection = new Win32::OLE('ADODB.Connection'); my $rs = new Win32::OLE("ADODB.Recordset"); my $db_datasource = 'Driver={Microsoft Access Driver (*.mdb)}; +'; # My database is called test.mdb and is in the same dir. $db_datasource .= 'DBQ=test.mdb'; # Connect to the database and tie the recordset object to # the database. $db_connection->Open($db_datasource); # Set the connection doohickey $rs->CursorLocation(adUseClient); $rs->Open('test', $db_connection, adOpenKeySet);

I did a quick test on my win2k machine with an access2000 database and it ran without error (note that this is a DSN less connection). I hope that gives you a starting point :)
Cheers - Simon

In reply to Re: Cannot insert into MS Access Memo field with DBI by simon.proctor
in thread Cannot insert into MS Access Memo field with DBI by drewbert2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-03-19 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found