[求助]关于函数参数的问题
代码如下: Public Function GetID(ByVal s2 As String, ByVal s3 As String) As Integer
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
Dim str As String
Dim ID As Integer
str = "select * from s3 Where Name='s2'"
Dim mycom1 As New SqlCommand(str, mycon)
Dim myreader1 As SqlDataReader
myreader1 = mycom1.ExecuteReader
While myreader1.Read
ID = myreader1("ID")
Return ID
End While
mycon.Close()
End Function
运行报错,说对象s3,和s2无效
我也知道原因:也就是传入的参数,s2,s3所表示的实参没有改变,还是行参s2和s3,有没有办法,在连接字符串里面
将实参传到字符串里面,谢谢