代码如下:Private Sub ComSave_Click()     '保存信息
 rs1.Open "select * from fstudent where 编号='" & Trim(Text2(0).Text) & "'", cnn, adOpenKeyset, adLockPessimistic
 If rs1.RecordCount > 0 Then
     For i = 0 To 20
       If Text2(i).Text <> "" Then rs1.Fields(i) = Trim(Text2(i).Text)
       Text2(i).Enabled = False
     Next i
     rs1.Update
     Adodc1.Refresh
     a = MsgBox("保存完毕!", vbInformation, "提示")
 End If
 rs1.Close     '关闭数据集对象
End Sub问题出在:编号='" & Trim(Text2(0).Text) & "'   (因为编号我是按自动编号保存的,使用的数据库是Access)
谢谢关注此帖的朋友!!!解决就揭贴。

解决方案 »

  1.   

    编号=" & Trim(Text2(0).Text) & "
    不要单引号
      

  2.   

    同意楼上,在SQL SERVER中可以这样写,但在ACCESS中不行。
      

  3.   

    编号是数字类型的话,就不能用引号了
    rs1.Open "select * from fstudent where 编号=" & Trim(Text2(0).Text) & "", cnn, adOpenKeyset, adLockPessimistic