主题:[讨论]高手请进
我这是个数据库转换的程序,运行总是出现错误麻烦高手帮忙修改下!谢谢我急用~
Private Sub CmdEnd_Click()
Unload Me
End Sub
Private Sub CmdZhuanhuan_Click()
Dim DB As Database, EF As Recordset
Dim X, y, i As Integer
Dim DB2 As Database, EF2 As Recordset
Dim TempStr As String
cnnstr = App.Path
cnnstr = cnnstr & "/DataBase/db3.mdb"
'TempStr = ""
'TempStr = "update Result; set RecordName=Source.RecordName ; from Result,Source ; where Source.RecordNUM=Result.RecordNUM)"
'TempStr = "UPDATE Result set RecordName='aaa' WHere RecordNUM='456'"
'TempStr = "UPDATE Result set RecordName=Source.RecordName- From Result,Source- WHere Result.RecordNUM=Source.RecordNUM"
strName = ";UID=;PWD="
Set DB = OpenDatabase(cnnstr, False, False, strName)
Set EF = DB.OpenRecordset("sheet1", dbOpenTable)
Set DB2 = OpenDatabase(cnnstr, False, False, strName)
Set EF2 = DB2.OpenRecordset("wzkjiu", dbOpenTable)
X = EF.RecordCount
EF.MoveFirst
EF2.MoveFirst
For i = 0 To X - 1
y = EF.Fields(1).Value
TempStr = ""
TempStr = TempStr & "'" & EF.Fields(9).Value & "'" & " "
TempStr = "wzjhdj=" & TempStr
TempStr = TempStr & " " & "Where wjbh=" & "'" & y & "'"
TempStr = "UPDATE wzkjiu set" & " " & TempStr
DB2.Execute TempStr, dbFailOnError
EF.MoveNext
Next
'DB2.Execute TempStr, dbFailOnError
End Sub
Private Sub Form_Load()
Dim DB As Database, EF As Recordset
Dim X, y As Integer
Dim DB2 As Database, EF2 As Recordset
cnnstr = App.Path
cnnstr = cnnstr & "/DataBase/db3.mdb"
strName = ";UID=;PWD="
Set DB = OpenDatabase(cnnstr, False, False, strName)
Set EF = DB.OpenRecordset("sheet1", dbOpenTable)
Set DB2 = OpenDatabase(cnnstr, False, False, strName)
Set EF2 = DB2.OpenRecordset("wzkjiu", dbOpenTable)
X = EF.RecordCount
y = EF2.RecordCount
EF.MoveFirst
Label1.Caption = X
Label2.Caption = y
End Sub
Private Sub CmdEnd_Click()
Unload Me
End Sub
Private Sub CmdZhuanhuan_Click()
Dim DB As Database, EF As Recordset
Dim X, y, i As Integer
Dim DB2 As Database, EF2 As Recordset
Dim TempStr As String
cnnstr = App.Path
cnnstr = cnnstr & "/DataBase/db3.mdb"
'TempStr = ""
'TempStr = "update Result; set RecordName=Source.RecordName ; from Result,Source ; where Source.RecordNUM=Result.RecordNUM)"
'TempStr = "UPDATE Result set RecordName='aaa' WHere RecordNUM='456'"
'TempStr = "UPDATE Result set RecordName=Source.RecordName- From Result,Source- WHere Result.RecordNUM=Source.RecordNUM"
strName = ";UID=;PWD="
Set DB = OpenDatabase(cnnstr, False, False, strName)
Set EF = DB.OpenRecordset("sheet1", dbOpenTable)
Set DB2 = OpenDatabase(cnnstr, False, False, strName)
Set EF2 = DB2.OpenRecordset("wzkjiu", dbOpenTable)
X = EF.RecordCount
EF.MoveFirst
EF2.MoveFirst
For i = 0 To X - 1
y = EF.Fields(1).Value
TempStr = ""
TempStr = TempStr & "'" & EF.Fields(9).Value & "'" & " "
TempStr = "wzjhdj=" & TempStr
TempStr = TempStr & " " & "Where wjbh=" & "'" & y & "'"
TempStr = "UPDATE wzkjiu set" & " " & TempStr
DB2.Execute TempStr, dbFailOnError
EF.MoveNext
Next
'DB2.Execute TempStr, dbFailOnError
End Sub
Private Sub Form_Load()
Dim DB As Database, EF As Recordset
Dim X, y As Integer
Dim DB2 As Database, EF2 As Recordset
cnnstr = App.Path
cnnstr = cnnstr & "/DataBase/db3.mdb"
strName = ";UID=;PWD="
Set DB = OpenDatabase(cnnstr, False, False, strName)
Set EF = DB.OpenRecordset("sheet1", dbOpenTable)
Set DB2 = OpenDatabase(cnnstr, False, False, strName)
Set EF2 = DB2.OpenRecordset("wzkjiu", dbOpenTable)
X = EF.RecordCount
y = EF2.RecordCount
EF.MoveFirst
Label1.Caption = X
Label2.Caption = y
End Sub