2楼代码通用,不过可以改进: Dim S As String = e.Form.Controls("TextBox1").Value Dim cmd As New SQLCommand cmd.Connection name = "数据原名称" cmd.CommandText = "SELECT Count(*) From {送货地址} Where [客户] = '"& S &"'" If cmd.ExecuteScalar > 0 Then Messagebox.show("已经存在数据!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Else Messagebox.show("可以增加数据, !","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) End If
|