快,速度解决就去睡觉(数据添加问题)
想添加个记录,如果学号存在就退出
自己想很久解决不了,求助
代码:
Dim sql As String
---------------
sql = "selcet * from studentinfo where 学号= ' " & Trim(Text1(0).Text) & " ' "
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open sql, conn, 3, 3
If rs.RecordCount > 0 Then
MsgBox "已存在的学号! ", 1 + 16, "警告 "
Else
rs.AddNew
For i = 0 To 12
rs.Fields(i) = Text1(i).Text
Next i
rs.Update
MsgBox "信息添加成功! ", vbOKOnly, "确认 "
End If
Set rs = Nothing
End Sub
谢谢
[解决办法]
sql = "selcet * from studentinfo where 学号= ' " & Trim(Text1(0).Text) & " ' "
上面的 'selcet '应为select查询语句。