FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Long File Names with ADO
Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM

Long File Names with ADO

Posted: 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 (fw): Select all Collapse
  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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Long File Names with ADO

Posted: Wed Sep 19, 2012 03:18 AM
Code (fw): Select all Collapse
      :Source           := "SELECT * FROM [tblDeposits 2012]"
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Long File Names with ADO

Posted: Wed Sep 19, 2012 03: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 (fw): Select all Collapse
   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

Continue the discussion