Rick,
I am using ADO (Jet) and Access for several tests.
Thanks for the URL to update Jet, I will try it on such laptop
oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
// check for very first user
cSQL := "SELECT * FROM USERINFO"
TRY
oRs:Open( cSQL, xCONNECT ) // you can use the FW_function Antonio mentioned above as well
CATCH oErr
Saying := "Error in Opening USERINFO table to"+chr(10)
Saying += "Create the First Admin User"+chr(10)
MsgInfo( Saying )
oCn:Close()
oDlg:End()
RETURN(.F.)
END TRY
cLOGIN := UPPER( WNetGetuser() )+space(25) // fivewin
cLOGIN := SUBSTR(cLOGIN,1,25)
If file( cDefa+"\Userinfo.dbf" )
cSay := "Importing Legacy Users "
oSay:ReFresh()
Select 1
If NetUse( cDefa+"\Userinfo.Dbf",.t.,5)
Set Order to tag Userid
Else
oCn:Close()
oDlg:End()
Return(.f.)
Endif
nEid := 1
Select UserInfo
Go Top
Do While .not. Eof()
cSay := "Importing Legacy Users "+UserInfo->UserId
oSay:ReFresh()
SysReFresh()
If Userinfo->UserId = " "
Select UserInfo
Skip
Loop
Endif
cEid := StrZero(nEid,18)
oRs:AddNew()
oRs:Fields("UserEid"):Value := cEid
oRs:Fields("UserId"):Value := substr(UserInfo->UserId+space(25),1,25)
oRs:Fields("Lname"):Value := substr(UserInfo->Lname+space(15),1,15)
oRs:Fields("Fname"):Value := substr(UserInfo->Fname+space(1),1,1)
oRs:Fields("ReadOnly"):Value := if(UserInfo->Read = " ", "Y", UserInfo->Read)
oRs:Fields("WriteOnly"):Value := if(UserInfo->Write = " ", "N", UserInfo->Write)
oRs:Fields("Super"):Value := if(UserInfo->Super = " ", "N", UserInfo->Super)
oRs:Fields("Admin"):Value := if(UserInfo->Admin = " ", "N", UserInfo->Admin)
oRs:Fields("EntryBy"):Value := if(UserInfo->EntryBy = " ", "Import", UserInfo->EntryBy)
oRs:Fields("EntryDate"):Value := if(UserInfo->EntryDate = ctod(""),;
dtoc(Date())+" "+Time(),UserInfo->EntryDate )
oRs:Fields("LastLog"):Value := UserInfo->LastLog
oRs:Fields("Password"):Value := Space(16)
oRs:Fields("UpDated"):Value := if(UserInfo->Updated = 0, 1, UserInfo->Updated )
oRs:Update()
nEid++
Select UserInfo
Skip
Enddo
Close Databases
Endif
Select Userinfo
Go top
DO while .not eof
If deleted()
select Userinfo
skip
loop
endif
... recordset code migration as above
...
select userinfo
skip
EndDo
cSql := "Select * from [Customer] where [State] = 'SC'"
or
cState := "SC"
cSql := "Select * from [Customer] where [State] = '"+cState+"'"
or with a filter condition .. sorted by
cState := "SC"
cSql := "Select * from [Customer] Order by [State],[City]"
oRs:Filter := "[State] = '"+cState+"'"
FWH 13.05
Function UsarAcces()
Local oCon
Local cBase := "archivo.mdb"
Local oCatalog
if ! File( cBase )
if MsgYesNo( cBase+" no encontrada" + CRLF + "Quieres crearla ?" )
oCatalog := CreateObject("ADOX.Catalog")
oCatalog:Create("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type = 5 ;Data Source="+cBase)
oCon = TOleAuto():New( "ADODB.Connection" )
oCon:Open( "Provider='Microsoft.Jet.OLEDB.4.0'; Data Source='archivo.mdb';" )
MsgInfo( "Cerrar" )
oCon:Close()
endif
else
MsgInfo("La Base de datos EXISTE")
// Abro la base de datos
oCon = TOleAuto():New( "ADODB.Connection" )
oCon:Open( "Provider='Microsoft.Jet.OLEDB.4.0'; Data Source='archivo.mdb';" )
MsgInfo( "Cerrar" )
oCon:Close()
endif
Jet OLEDB:Engine Type = 5
Jet OLEDB:Engine Type A Long value (read/write) that specifies which Jet database engine I-ISAM driver to use to access this database or file format. When you create a new database by using the Create method of the ADOX Catalog object, this can be used to specify the format for the new database. Once a database has been opened, this property can be read to determine what file version or format is open.
The Jet OLEDB:Engine Type property can be any of the following values:
Engine Type Setting
Unknown 0
Microsoft Jet 1.0 1
Microsoft Jet 1.1 2
Microsoft Jet 2.0 3
Microsoft Jet 3.x 4
Microsoft Jet 4.x 5
oMdbTable := AdoOpenTable( oCon, cTblMdb )
oMdbTable: = AdoOpenTable (oCon, cTblMdb)
He conseguido llegar a poder seleccionar y abrir una Tabla:
1.- Lo he hecho con .Schema(20), hay otra forma?, puede servir ADOX.Table?
4.- Cómo puedo saber la estructura de la tabla activa?
Creo que es con el ADODB.RecorSet y ejecutando una sentencia a través de ADODB.Command
pero eso es ya bastante complicado para mí. Hay otra forma?
cTabla := oCat:Tables( i ):Name
cTipo := oCat:Tables( i ):Type
? oCat:Tables( i ):Columns( j ):Name // Devuelve bien el nombre del campo
? oCat:Tables( i ):Columns( j ):Type // Devuelve siempre 130 ¿?
I managed to get to be able to select and open a table:
1. - I've done it. Schema (20), there is another way?, Can serve ADOX.Table?
4. - How I can know the structure of the active table?
I think it's with ADODB.RecorSet and executing an ADODB.Command through
but it is already quite complicated for me. Is there another way?
cTabla := oCat:Tables(i):Name
cType := oCat:Tables(i):Type
? oCat:Tables(i):Columns(j):Name / / Returns either the field name
? oCat:Tables(i):Columns(j):Type / / Returns always 130?
Qué significa el 130 ?
#define adEmpty 0
#define adTinyInt 16
#define adSmallInt 2
#define adInteger 3
#define adBigInt 20
#define adUnsignedTinyInt 17
#define adUnsignedSmallInt 18
#define adUnsignedInt 19
#define adUnsignedBigInt 21
#define adSingle 4
#define adDouble 5
#define adCurrency 6
#define adDecimal 14
#define adNumeric 131
#define adBoolean 11
#define adError 10
#define adUserDefined 132
#define adVariant 12
#define adIDispatch 9
#define adIUnknown 13
#define adGUID 72
#define adDate 7
#define adDBDate 133
#define adDBTime 134
#define adDBTimeStamp 135
#define adBSTR 8
#define adChar 129
#define adVarChar 200
#define adLongVarChar 201
#define adWChar 130
#define adVarWChar 202
#define adLongVarWChar 203
#define adBinary 128
#define adVarBinary 204
#define adLongVarBinary 205
#define adChapter 136
#define adFileTime 64
#define adPropVariant 138
#define adVarNumeric 139
#define adArray 8192
Return to Off Topic / Otros temas
Users browsing this forum: No registered users and 6 guests