我在下面有以下 ASP.NET (VB) 代码。我的目标是获取接受 1 个参数的存储过程的输出并将该信息存储到数据表中:
Dim strConnection1 As String = System.Configuration.ConfigurationManager.AppSettings("Rdf2012")
Dim conn1 As System.Data.SqlClient.SqlConnection
conn1 = New System.Data.SqlClient.SqlConnection(strConnection1)
Dim cmd1 As New SqlCommand
Dim prm1 As New SqlParameter
Dim dtDataTable1 As DataTable
cmd1.Connection = conn1
cmd1.CommandText = "usp_GetDetails"
cmd1.CommandType = CommandType.StoredProcedure
prm1 = cmd1.Parameters.Add(strProgramID, SqlDbType.VarChar, 50)
prm1.Direction = ParameterDirection.Input
conn1.Open()
Dim dataAdapter As New SqlDataAdapter
dataAdapter.SelectCommand = cmd1
Dim ds1 As New DataSet
dataAdapter.Fill(ds1)
conn1.Close()
dtDataTable1 = ds1.Tables("Table1")
程序停在
dataAdapter.Fill(ds1) and says:
@1012952-4403 不是过程 usp_GetDetails 的参数
这是存储过程的样子:
ALTER PROCEDURE [dbo].[usp_GetDetails]
@ProId VARCHAR(20) = NULL
AS