实际上,我试图找出partno是否存在于数据库表中,并且在count = checkCommand.ExecuteReader sataement中需要很长时间
请在下面找到方法
Public Function CheckProductNo(ByVal Partno As String) As Boolean
Dim count As SqlDataReader
Dim valid As Boolean = False
Using connection As New SqlConnection
connection.Open()
Using checkCommand As New SqlCommand("PartNo_check", connection)
checkCommand.CommandType = CommandType.StoredProcedure
checkCommand.Parameters.Add(New SqlParameter("@PartNo", Partno))
count = checkCommand.ExecuteReader
If count.ToString > 0 Then
valid = True
End If
End Using
End Using
Return valid
End Function
STORED PROCEDURE
CREATE PROCEDURE PartNo_Check
@PartNo VARCHAR(30)
AS
SELECT PartNo from T_Product where PartNo=@Partno
Thanks