#110120 - 2003-12-11 07:22 PM
MODIFY ACCES DATABASE
|
@lejo @rias
Starting to like KiXtart
Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
|
Hi, how I do to modify one file.mdb (access 97) whit kixtart?
_________________________
Look always 4 the best...
|
|
Top
|
|
|
|
#110123 - 2003-12-11 08:06 PM
Re: MODIFY ACCES DATABASE
|
@lejo @rias
Starting to like KiXtart
Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
|
I use
this script Code:
$dsn='DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\journal.mdb' $sql="INSERT INTO PARAMETROS VALUES('eee','fff')" $recordset = DBCommand($dsn,$sql) ? 'Error = '+@ERROR+' - '+@SERROR $sql="SELECT Field1, Field2 FROM Table1" $recordset = DBCommand($dsn,$sql) ? 'Error = '+@ERROR+' - '+@SERROR For $row=0 to Ubound($recordset,1) For $column=0 to Ubound($recordset,2) ? 'Field(row='+$row+', column='+$column+') ='+$recordset[$row,$column] Next Next
Function DBCommand($ConnDSN,$sql) Dim $objConn, $adStateOpen Dim $Conntimeout, $CmdTimeout Dim $cmdCommand, $rsRecordset Dim $Records, $FinalRecords Dim $adCmdText, $adLockReadOnly, $adOpenStatic Dim $row, $rows, $column, $columns
$ConnDSN=Trim($ConnDSN) If NOT $ConnDSN Exit 87 EndIf $sql=Trim($sql) If NOT $sql Exit 87 EndIf
; default database parameters $adStateOpen=1 $ConnTimeout=15 $CmdTimeout=30 $adCmdText = 1 $adOpenStatic = 3 $adLockReadOnly = 1
; open the database connection $objConn = CreateObject("ADODB.Connection") If @ERROR Exit @ERROR EndIf $objConn.ConnectionTimeout = $ConnTimeout If @ERROR Exit @ERROR EndIf $objConn.CommandTimeout = $CmdTimeout If @ERROR Exit @ERROR EndIf $objConn.Open($ConnDSN) If @ERROR Exit @ERROR EndIf If NOT $objConn.State=$adStateOpen $objConn='' $DBCommand='' Exit @ERROR EndIf
; create the database command object $cmdCommand = CreateObject('ADODB.Command') If @ERROR Exit @ERROR EndIf $cmdCommand.ActiveConnection = $objConn If @ERROR Exit @ERROR EndIf $cmdCommand.CommandType = $adCmdText If @ERROR Exit @ERROR EndIf $cmdCommand.CommandText = $sql If @ERROR $DBCommand=@ERROR Exit @ERROR EndIf
If InStr($sql,'SELECT')=1 ; create the recordset object $rsRecordSet = CreateObject('ADODB.Recordset') If @ERROR Exit @ERROR EndIf $rsRecordset.CursorType = $adOpenStatic If @ERROR Exit @ERROR EndIf $rsRecordset.LockType = $adLockReadOnly If @ERROR Exit @ERROR EndIf $rsRecordset.Open($cmdCommand) If @ERROR Exit @ERROR EndIf
If $rsRecordset.EOF AND $rsRecordSet.BOF ; recordset is empty $FinalRecords='' Else If @ERROR Exit @ERROR EndIf
; retrieve all records at once and transpose into tabular format $Records = $rsRecordset.GetRows() $columns=Ubound($records,1) $rows=Ubound($records,2) ReDim $FinalRecords[$rows,$columns] For $row=0 to $rows For $column=0 to $columns $FinalRecords[$row,$column]=$records[$column,$row] Next Next EndIf
; close recordset If $rsRecordset.state=$adStateOpen $rsRecordset.Close() If @ERROR Exit @ERROR EndIf EndIf
$rsRecordset='' $cmdCommand=''
$DBCommand=$FinalRecords Else $rsRecordset=$cmdCommand.Execute() $cmdCommand='' $rsRecordset='' If @ERROR Exit @ERROR EndIf
$DBCommand=0 EndIf
; close the database connection If $objConn.State = $adStateOpen $objConn.Close() If @ERROR Exit @ERROR EndIf EndIf $objConn=''
Exit 0 EndFunction
and return
Error = -2147352567 - COM exception error "Open" (Microsoft OLE DB Provider for ODBC Drivers - [Microsoft][Administrador de controladores ODBC] El nombre del or igen de datos no se encontró y no se especificó ningún controlador predeterminad o) [-2147352567/80020009] Error = -2147352567 - COM exception error "Open" (Microsoft OLE DB Provider for ODBC Drivers - [Microsoft][Administrador de controladores ODBC] El nombre del or igen de datos no se encontró y no se especificó ningún controlador predeterminad o) [-2147352567/80020009] C:\>
_________________________
Look always 4 the best...
|
|
Top
|
|
|
|
#110125 - 2003-12-11 08:20 PM
Re: MODIFY ACCES DATABASE
|
@lejo @rias
Starting to like KiXtart
Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
|
 I´m sorry seal, I don´t read the full code, I comment the second part but return
Error = -2147352567 - COM exception error "Open" (Microsoft OLE DB Provider for ODBC Drivers - [Microsoft][Administrador de controladores ODBC] El nombre del or igen de datos no se encontró y no se especificó ningún controlador predeterminad o) [-2147352567/80020009] C:\>
How I know If have the drivers correct? My pc don´t have microsft access program. And I can't install it.
I write
$dsn='DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\journal.mdb' $sql="INSERT INTO PARAMETROS VALUES('eee','fff')" $recordset = DBCommand($dsn,$sql) ? 'Error = '+@ERROR+' - '+@SERROR
;$sql="SELECT Field1, Field2 FROM PARAMETROS" ;$recordset = DBCommand($dsn,$sql) ;? 'Error = '+@ERROR+' - '+@SERROR ;For $row=0 to Ubound($recordset,1) ; For $column=0 to Ubound($recordset,2) ; ? 'Field(row='+$row+', column='+$column+') ='+$recordset[$row,$column] ; Next ;Next
func.....
_________________________
Look always 4 the best...
|
|
Top
|
|
|
|
#110129 - 2003-12-11 10:13 PM
Re: MODIFY ACCES DATABASE
|
@lejo @rias
Starting to like KiXtart
Registered: 2003-09-02
Posts: 100
Loc: Medellin, Colombia
|
tks
Break on ? "indique fecha" Gets $x $dsn='DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\journal.mdb' $sql="update parametros set fecha_sistema="+$x+", fecha_efectiva="+$x ?$sql Get $x $recordset = DBCommand($dsn,$sql) ? 'Error = '+@ERROR+' - '+@SERROR
work now.
_________________________
Look always 4 the best...
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 302 anonymous users online.
|
|
|