哪错了???
Private Sub Command1_Click()Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim cmd1 As New ADODB.Command
Dim cmd2 As New ADODB.Command
Dim str As String
Dim str2(0 To 2) As String
Call contooledb
Set cmd1.ActiveConnection = sqlcon
Set cmd2.ActiveConnection = sqlcon
cmd1.CommandText = "select * from xian1"
Set rs = cmd1.Execute
Open "D:\3.txt" For Input As #1
'Open "D:\4.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, str
' Dim a As Long
'a = Len(str)
' 'MsgBox a
'Print #2, str
str2(0) = Trim(Mid$(str, 1, 10))
str2(1) = Trim(Mid$(str, 12, 1))
str2(2) = Trim(Mid$(str, 14, 4))
'Print #2, str2(1)
Do While Not rs.EOF
'Print #2, rs!id
If (rs!Type = str2(1)) Then
If (rs!date1 > rs!date2) Then
cmd2.CommandText = "update xian1 set date2 = '" & str2(0) & " ' where id= '" & rs!id & " ' "
cmd2.Execute
cmd2.CommandText = "update xian1 set weight2 = '" & str2(2) & " ' where id= '" & rs!id & " ' "
cmd2.Execute
Else
cmd2.CommandText = "update xian1 set date1='" & str2(0) & " ' where id= '" & rs!id & "'"
cmd2.Execute
cmd2.CommandText = "update xian1 set weight2=' " & str2(2) & " 'where id= '" & rs!id & "'"
cmd2.Execute
End If
End If
rs.MoveNext
'Print #2, rs!id
Loop
Loop
Close #1
rs.Close
MsgBox "更新成功!!"
我想更新表中的每个type字段,假设type有a和b两种类型,可当执行程序时,每次只能更新type为a的,为什么???????
我这个程序错在哪????
End Sub