VB2005向SQL储存查询传递参数问题
请问使用VB2005怎么给SQL的储存过程传递参数?谢谢!
[解决办法]
Private Sub SetParametersAndGetData()
Dim dsNorthwind1 As New DataSet()
Dim da As New SqlClient.SqlDataAdapter()
Dim cmd As New SqlClient.SqlCommand()
Dim param As SqlClient.SqlParameter
cmd.CommandText = "SalesByCategory "
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = dcNorthwind
param = New SqlClient.SqlParameter()
param.ParameterName = "@CategoryName "
param.SqlDbType = SqlDbType.NVarChar
param.Value = "Condiments "
cmd.Parameters.Add(param)
param = New SqlClient.SqlParameter()
param.ParameterName = "@OrdYear "
param.SqlDbType = SqlDbType.NVarChar
param.Value = "1998 "
cmd.Parameters.Add(param)
da.SelectCommand = cmd
da.Fill(dsNorthwind1)
End Sub