请问这个用VB往SQL添加信息的代码哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/06/06 02:57:46
Private Sub cmdCancle_Click()
Unload Me

End Sub

Private Sub cmdOK_Click()
Dim txtsql As String
If txtNo.Text = "" Then
MsgBox "请输入ID", vbOKOnly + vbExclamation, "警告"
txtNo.SetFocus
Exit Sub
End If
If txtName.Text = "" Then
MsgBox "请输入名称", vbOKOnly + vbExclamation, "警告"
txtName.SetFocus
Exit Sub
End If
If txtPrice.Text = "" Then
MsgBox "请输入价格", vbOKOnly + vbExclamation, "警告"
txtPrice.SetFocus
Exit Sub
End If
If txtType.Text = "" Then
MsgBox "请输入类型", vbOKOnly + vbExclamation, "警告"
txtType.SetFocus
Exit Sub
End If
txtsql = "select*from goodsinfo where ID='" & Trim(txtNo.Text) & "'"
cmd.CommandText = txtsql
ser mrc = cmd.Execute
If mrc.EOF = False Then
MsgBox "ID重复,请重新输入", vbOKOnl

没有看到连接字符串,也没有打开连接
ser mrc = cmd.Execute 应该是set...

txtsql = "select*from goodsinfo where ID='" & Trim(txtNo.Text) & "'"

这里的字段ID是什么类型的