Creating and openinng Access Database with passwords. ( Both mdb and accdb )
Creating an access database with password:
FW_CreateMDB( "c:\fwh\samples\mdbpwd.mdb", "mypassword" )
Opening:
1) Using connection string:
cStr := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\fwh\samples\mdbpwd.mdb;Jet OLEDB:Database Password=mypassword;"
oCn := FW_OpenAdoConnection( cStr, .t. )
2) Using FWH Connection Spec:
oCn := FW_OpenAdoConnection( "c:\fwh\samples\mdbpwd.mdb,mypasword", .t. )
3) Using FWH command syntax
ADOCONNECT oCn TO MSACCESS c:\fwh\samples\mdbpwd.mdb PASSWORD mypassword
Pasar datos de una tabla DBF a una de access
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Pasar datos de una tabla DBF a una de access
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Pasar datos de una tabla DBF a una de access
Migrating from Access to MySql
Please try this program:
In the above program, please replace your servername, database. username and password.
If the mdb file is password protected:
Please try this program:
Code: Select all
#include "fivewin.ch"
#include "adodef.ch"
function Main()
local oCn, oRs
? "Connecting to mysql server"
ADOCONNECT oCn TO MYSQL SERVER localhost DATABASE FWH USER root PASSWORD yourpassword
if oCn == nil .or. oCn:State == 0
? "Fail to connect to mysql"
return nil
endif
? "Importing CUSTOMER table from c:\fwh\samples\xbtrest.mdb"
MDB2MYSQL( oCn, "c:\fwh\samples\xbrtest.mdb", "CUSTOMER" )
? "Browse the imported table"
oRs := FW_OpenRecordSet( oCn, "CUSTOMER" )
XBROWSER oRs AUTOSORT
oRs:Close()
oCn:Close()
return nil
function MDB2MYSQL( oCnMySql, cMdb, cTable )
local oCnMDB, oRs, aRows, aStruct, lHasAutoInc, aCols
local cSql, cExecSql, nRow, n
local nBatchSize := 100
oCnMDB := FW_OpenAdoConnection( cMdb, .t. )
oRs := FW_OpenRecordSet( oCnMDB, cTable )
aStruct := FWAdoStruct( oRs )
if oRs:RecordCount() > 0
aRows := oRs:GetRows()
oRs:MoveFirst()
oRs:Close()
oCnMDB:Close()
endif
TRY
oCnMySQL:Execute( "DROP TABLE " + cTable )
CATCH
END
lHasAutoInc := ( aStruct[ 1, 2 ] == '+' )
FWAdoCreateTable( cTable, aStruct, oCnMySQL, !lHasAutoInc )
aCols := ArrTranspose( aStruct )[ 1 ]
ADel( aCols, 1, .t. )
AEval( aCols, { |c,i| aCols[ i ] := Chr(96) + c + Chr(96) } )
aCols := FW_ArrayAsList( aCols )
cSql := "INSERT INTO " + cTable + " ( " + aCols + " ) VALUES "
n := 0
for nRow := 1 to Len( aRows )
aCols := aRows[ nRow ]
if lHasAutoInc
ADel( aCols, 1, .t. )
endif
aCols := FW_ValToSQL( aCols )
if n == 0
cExecSQL := cSql + aCols
else
cExecSQL += "," + aCols
endif
if n >= nBatchSize .or. nRow >= Len( aRows )
TRY
oCnMySQL:Execute( cExecSQL )
CATCH
FW_ShowAdoError()
QUIT
END
n := 0
else
n++
endif
next nRow
return nil
If the mdb file is password protected:
Code: Select all
MDB2MYSQL( oCn, "c:\fwh\samples\xbrtest.mdb,mypassword", "CUSTOMER" )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Pasar datos de una tabla DBF a una de access
Regards
Saluditos
Saluditos
Que es mejor que programar? creo que nada
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ
Atropellada pero aqui ando
I love Fivewin
séʌǝɹ ןɐ ɐʇsǝ opunɯ ǝʇsǝ