string connection MS Access

string connection MS Access

Postby kajot » Mon Aug 19, 2013 6:36 pm

wthat is string connection Ms Acces to mdb file with password

best regard
kajot
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: string connection MS Access

Postby Rick Lipkin » Mon Aug 19, 2013 7:15 pm

kajot

Here is a sample connection string for Ms Access with a password... see the variable xString.

Rick Lipkin
Code: Select all  Expand view  RUN


//-- get location of .exe assuming the .mdb is in the same folder //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

xPROVIDER := "
Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"
\YourTable.mdb"
xPASSWORD := "
xxxxxx"

xSTRING := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet OLEDB:Database Password='+xPASSWORD
 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: string connection MS Access

Postby nageswaragunupudi » Mon Aug 19, 2013 8:20 pm

From FWH 13.06 onwards we can open access (mdb or accdb) files with password using:

oCn := FW_OpenAdoConnection( <cmdbfilename>, <cpassword> )

The function internally builds the proper connection string.
Regards

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

Re: string connection MS Access

Postby lucasdebeltran » Tue Aug 20, 2013 8:41 am

Mr. Nages,

In source\function\adofuncions.prg this is what I have:


function Fw_OpenAdoConnection( cConnStr, lShowError )


Nothing about password.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: string connection MS Access

Postby nageswaragunupudi » Tue Aug 20, 2013 4:32 pm

Mr Lucas

Regret my inaccuracy in the syntax.
The correct syntax is:
oCn := FW_OpenAdoConnection( "<cmdbfilename>,<cpassword>" )

Example:
Create a password protected mdb file with:
FW_CreateMDB( "c:\mydata\tutor05.mdb", "mypassword" )

and open it with
oCn := FW_OpenAdoConnection( "c:\mydata\tutor05.mdb,mypassword" )
OR
oCn := FW_OpenAdoConnection( { "c:\mydata\tutor05.mdb", "mypassword" } )
Regards

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

Re: string connection MS Access

Postby kajot » Wed Aug 21, 2013 4:36 pm

thanks for answer

but if I use
cPath := cFilePath( ExeName() )
xSOURCE := cPATH+"waga.mdb"
xPASSWORD := "123456"

oCon := FW_OpenAdoConnection( xSOURCE,xPASSWORD)

cSQL:="select idklienta, nazwa, adres, nip from Klienci"
oRes := FW_OpenRecordSet( oCon, cSQL )

the function FW_OpenRecordSet( oCon, cSQL ) retrun error openning table Klienci

best regards
kajot
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: string connection MS Access

Postby nageswaragunupudi » Wed Aug 21, 2013 10:51 pm

Please use:
oCon := FW_OpenAdoConnection( { xSOURCE, xPASSWORD } )

or

oCon := FW_OpenAdoConnection( xSOURCE + "," + xPASSWORD)
Regards

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

Re: string connection MS Access

Postby kajot » Fri Aug 23, 2013 6:45 am

if I used function
oCon := FW_OpenAdoConnection( xSOURCE + "," + xPASSWORD)

the database opened good, but the function FW_OpenRecordSet can't open the table

cSQL:="select idklienta, nazwa, adres, nip from Klienci"
oRes := FW_OpenRecordSet( oCon, cSQL )

best regards
kajot
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: string connection MS Access

Postby nageswaragunupudi » Fri Aug 23, 2013 5:35 pm

It is working here for me.
Example code:
Code: Select all  Expand view  RUN
function TestPW

   local oCn, oRs
   local cmdb := "tutorpw.mdb"
   local pwd  := "12345"

   if ! File( cmdb )
      if ! FW_CreateMDB( cmdb, pwd )
         ? "MDB Create Fail"
         return nil
      endif
   endif

   oCn   := FW_OpenAdoConnection( cmdb + ","  pwd )
   if oCn == nil
      ? "Connect fail"
      return nil
   endif

   FW_AdoImportFromDBF( oCn,  "c:\fwh\samples\CUSTOMER.DBF" )

   xbrowser fw_adotables( oCn )

   oRs := FW_OpenRecordSet( oCn, "CUSTOMER" )
   ? oRs:State

   xbrowser oRs
   oRs:Close()
   oCn:Close()

return nil
 
Regards

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

Re: string connection MS Access

Postby kajot » Fri Aug 23, 2013 9:41 pm

thanks a lot

I can't check up our program, because I have FWH v. 12.06

so I got many error

xLINK: error: Unresolved external symbol '_HB_FUN_FW_CREATEMDB referenced from (t.obj)'.

xLINK: error: Unresolved external symbol '_HB_FUN_FW_ADOIMPORTFROMDBF referenced from (t.obj)'.

xLINK: error: Unresolved external symbol '_HB_FUN_FW_ADOTABLES referenced from (t.obj)'.


best regards
kajot
best regards
kajot
User avatar
kajot
 
Posts: 339
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland

Re: string connection MS Access

Postby nageswaragunupudi » Fri Aug 23, 2013 9:50 pm

Creation and Opening of MDB files with password is available from 13.06 only.
Regards

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

Re: string connection MS Access

Postby bpd2000 » Wed Aug 23, 2017 12:50 pm

Dear All,
I am unable to get connection using
oCn := FW_OpenAdoConnection( cmdb + "," + pwd )
when file extension of Access file is changed from .mdb to .bds
I need help how to connect
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
User avatar
bpd2000
 
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: string connection MS Access

Postby cnavarro » Wed Aug 23, 2017 1:03 pm

bpd2000 wrote:Dear All,
I am unable to get connection using
oCn := FW_OpenAdoConnection( cmdb + "," + pwd )
when file extension of Access file is changed from .mdb to .bds
I need help how to connect


You can try to modify the function FW_AdoConnectionString as well

Code: Select all  Expand view  RUN


function FW_AdoConnectionString( cConnSpec, nDb )

.../...

      elseif cExt $ "mdb,accdb,bds"
         cRDBMS      := "MSACCESS"

.../...

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: string connection MS Access

Postby bpd2000 » Wed Aug 23, 2017 1:16 pm

Thank you for reply
I tested but not succesful
Error as : Error description: Error BASE/1109 Argument error: $
Regards, Greetings

Try FWH. You will enjoy it's simplicity and power.!
User avatar
bpd2000
 
Posts: 153
Joined: Tue Aug 05, 2014 9:48 am
Location: India

Re: string connection MS Access

Postby cnavarro » Wed Aug 23, 2017 1:21 pm

bpd2000 wrote:Thank you for reply
I tested but not succesful
Error as : Error description: Error BASE/1109 Argument error: $


Put before

Code: Select all  Expand view  RUN

   ? cExt
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests