#88110 - 2002-09-20 11:39 AM
Clear Table in DB
|
Vig
Starting to like KiXtart
Registered: 2001-11-14
Posts: 166
Loc: Saudi Arabia
|
I'm able to delete the first record but I cannot delete more than one at a time.
code:
Function Cleardatabase() $RC=SetOption("WrapAtEOL","On") $DSN="Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DBPath$DBFile" $Connection = CreateObject("ADODB.Connection") $Command = CreateObject("ADODB.Command") $Recordset = CreateObject("ADODB.Recordset")
$Connection If @error = 0 ? "Connected" $Connection.ConnectionString = $DSN $Connection.Open() $Command.ActiveConnection = $Connection $Recordset.CursorType = 3 $Recordset.LockType = 3 $Recordset.ActiveCommand = $Command $DELETE_ALL = "SELECT * FROM TBL_PROGRAM WHERE COMPUTER <> '*';"
$Command.CommandText = $DELETE_ALL $Recordset.Open($Command) If $Recordset.RecordCount > 1 For $count = 1 to $Recordset.RecordCount $Recordset.Delete Next EndIf $Recordset.Update $Recordset.Close() ?"Completed Successfully" $Connection.Close() $Connection = 0 $Recordset = 0 $Command = 0 EndFunction
Thanks
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 182 anonymous users online.
|
|
|