Long File Names with ADO

Long File Names with ADO

Postby David Williams » Tue Sep 18, 2012 10:31 pm

Hi

I am trying to open a .mdb with ADO using long file names.

How do I connect to "Deposits 2012.mdb" and open the table "tblDeposits 2012"?

Code: Select all  Expand view

  local  cStr := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cFilePath( hb_argv( 0 ) ) + ;
      "deposits 2012.mdb;User Id=;Password=;"

   oConx := TOleAuto():new( "ADODB.connection" )
   oConx:ConnectionString := cStr
   oConx:Open()
   oRSet := TOleAuto():New( "ADODB.RecordSet" )

   With Object oRSet
      :CursorLocation   := adUseClient
      :CursorType       := adOpenDynamic
      :LockType         := adLockOptimistic
      :ActiveConnection := oConx
      :Source           := "SELECT * FROM tblDeposits 2012"
      :Open()
      :Sort             := :Fields( 0 ):Name
   End With
 


I have tried various forms of apostrophe's but I am unable to connect.

TIA
David
User avatar
David Williams
 
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Re: Long File Names with ADO

Postby nageswaragunupudi » Wed Sep 19, 2012 3:18 am

Code: Select all  Expand view
     :Source           := "SELECT * FROM [tblDeposits 2012]"
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Long File Names with ADO

Postby nageswaragunupudi » Wed Sep 19, 2012 3:23 am

FWH provides some useful functions for ADO which simplifies opening record sets.

We can open ADO connections and recordsets in this way
Code: Select all  Expand view
  oCn   := FW_OpenAdoConnection( cStr )
   if oCn != nil
      ? 'connected'
      oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM [tblDeposits 2012]" )
      if oRs != nil
         xbrowse( ors )
         ors:close()
      endif
      oCn:Close()
   endif
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests