2008年10月24日

如何replace 多個資料表中的特定字串-asp

Set myDB = DBEngine.Workspaces(0).OpenDatabase("", False, False, _
"ODBC;DSN=DSN名稱;Database=資料庫名稱;uid=使用者名稱;pwd=密碼")
For i = 0 To myDB.TableDefs.Count - 1
If myDB.TableDefs(i).Attributes = 0 Then
Set rs = myDB.OpenRecordset(myDB.TableDefs(i).Name, dbOpenDynaset, dbSeeChanges)
With rs
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
On Error Resume Next
.Edit
If Err.Number = 3027 Then
On Error GoTo 0
Exit Do
End If
On Error GoTo 0
For j = 0 To .Fields.Count - 1
Select Case .Fields(j).Type '欄位資料型態
Case 10, 12 '文字或備註欄位才處理
.Fields(j) = Replace(.Fields(j), "特定字串", "")
End Select
Next
.Update
.MoveNext
Loop
End If
End With
rs.Close
Set rs = Nothing
End If
Next
myDB.Close
Set myDB = Nothing

參考http://www.blueshop.com.tw/board/show.asp?subcde=BRD20080813191359FLO&fumcde=fum200410061525290ew

沒有留言: