我试图创建在参数传递到存储过程中的SQL服务器vb.net一些应用程序2008年,我已经试过这个代码,我不知道接下来该我写的
Public Function List(ByVal date As Date) As DataTable
Dim SPName As String = "usp_Name"
Dim dt As New DataTable
Try
oConn.Open()
Dim cmdSQL As New SqlCommand(SPName, oConn)
cmdSQL.CommandTimeout = 2000
cmdSQL.CommandType = CommandType.StoredProcedure
cmdSQL.Parameters.Add("@Date").Value = date //im not really sure this is the correct code
Dim da As New SqlDataAdapter(cmdSQL)
da.Fill(dt)
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
oConn.Close()
End Try
Return dt
End Function
它应该是
cmdSQL.Parameters.AddWithValue("@Date", date)
使用此代码
cmdSQL .Parameters.AddWithValue("@Date", date)