ExecuteScalar经常用来判断是否存在指定条件的数据,例如:
Dim cmd As New SQLCommandDim nm As String = "贺辉"cmd.Ccmd.CommandText ="Sele ct Count(*) From {Users} Where Name = '" & nm & "'"If cmd.ExecuteScalar > 0 Then Messagebox.Show("已经存在同名用户","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)End If