Necessario to make the modifications below in funcoes that they are in the ADORDD.PRG
Code: Select all
static function ADO_CREATE( nWA, aOpenInfo )
local cDataBase := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 1, ";" )
local cTableName := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 2, ";" )
local cDbEngine := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 3, ";" )
local cServer := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 4, ";" )
local cUserName := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 5, ";" )
local cPassword := HB_TokenGet( aOpenInfo[ UR_OI_NAME ], 6, ";" )
local oConnection := TOleAuto():New( "ADODB.Connection" )
local oCatalog := TOleAuto():New( "ADOX.Catalog" )
local aWAData := USRRDD_AREADATA( nWA )
local oError
do case
case Upper( Right( cDataBase, 4 ) ) == ".MDB"
if ! File( cDataBase )
oCatalog:Create( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDataBase )
endif
oConnection:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + cDataBase )
case Upper( cDbEngine ) == "MYSQL"
oConnection:Open( "DRIVER={MySQL ODBC 3.51 Driver};" + ;
"server=" + cServer + ;
";database=" + cDataBase + ;
";uid=" + cUserName + ;
";pwd=" + cPassword )
endcase
TRY
oConnection:Execute( "DROP TABLE " + cTableName )
CATCH
END
TRY
// oConnection:Execute( "CREATE TABLE [" + cTableName + "] (" + aWAData[ WA_SQLSTRUCT ] + ")" )
oConnection:Execute( "CREATE TABLE " + cTableName + "(" + aWAData[ WA_SQLSTRUCT ] + ")" )
CATCH
oError := ErrorNew()
oError:GenCode := EG_CREATE
oError:SubCode := 1004
oError:Description := HB_LANGERRMSG( EG_CREATE ) + " (" + ;
HB_LANGERRMSG( EG_UNSUPPORTED ) + ")"
oError:FileName := aOpenInfo[ UR_OI_NAME ]
oError:CanDefault := .T.
UR_SUPER_ERROR( nWA, oError )
END
oConnection:Close()
return SUCCESS
static function ADO_CREATEFIELDS( nWA, aStruct )
local aWAData := USRRDD_AREADATA( nWA )
local n
aWAData[ WA_SQLSTRUCT ] = ""
for n = 1 to Len( aStruct )
if n > 1
aWAData[ WA_SQLSTRUCT ] += ", "
endif
// aWAData[ WA_SQLSTRUCT ] += "[" + aStruct[ n ][ DBS_NAME ] + "]"
aWAData[ WA_SQLSTRUCT ] += aStruct[ n ][ DBS_NAME ]
Do case
case aStruct[ n ][ DBS_TYPE ] $ "C,Character"
aWAData[ WA_SQLSTRUCT ] += " CHAR(" + AllTrim( Str( aStruct[ n ][ DBS_LEN ] ) ) + ") NULL"
case aStruct[ n ][ DBS_TYPE ] == "N"
aWAData[ WA_SQLSTRUCT ] += " NUMERIC(" + AllTrim( Str( aStruct[ n ][ DBS_LEN ] ) ) + ")"
case aStruct[ n ][ DBS_TYPE ] == "L"
aWAData[ WA_SQLSTRUCT ] += " LOGICAL"
endcase
next
return SUCCESS