none
为什么系统会提示没有参数。我的存储过程instUpFileInfo明明有参数 RRS feed

  • 问题

  •     Protected Sub butUpFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butUpFile.Click
            Dim strSavePath As String = "F:\Visual Studio 2008\WebSites\FileSys\Department\SurveillanceCenter\Files\"
            Dim fileName As String = FileUpload.FileName
            Dim extension As String = System.IO.Path.GetExtension(fileName)
            Dim fileSize As Integer = FileUpload.PostedFile.ContentLength

            Dim sqlCommand As New SqlCommand
            Dim sqlConnect As New SqlConnection("Data Source=chengqiang;Initial Catalog=aspnetdb;Integrated Security=True")
            sqlConnect.Open()
            sqlCommand.Connection = sqlConnect
            sqlCommand.CommandType = Data.CommandType.StoredProcedure


            Dim UserId As String
            Dim Member As MembershipUser
            Member = Membership.GetUser()
            UserId = Member.UserName


            If FileUpload.HasFile Then
                If (fileSize < 5000000) Then
                    If extension = ".doc" Or extension = ".xlt" Or extension = ".txt" Or extension = ".pdf" Then
                        Dim DataTime As New DateTime
                        Dim UpData As Date = DataTime.Date
                        sqlCommand.CommandText = "instUpFileInfo"

                        sqlCommand.Parameters("@UserId").Value = UserId
                        sqlCommand.Parameters("@FileName").Value = fileName
                        sqlCommand.Parameters("@FilePath").Value = strSavePath

                        sqlCommand.ExecuteNonQuery()

     

     

     

    2010年4月1日 15:16

答案

  • Hi,

    sqlCommand.Parameters.AddWithValue("@UserId", UserId)
    sqlCommand.Parameters.AddWithValue("@FileName", fileName)
    sqlCommand.Parameters.AddWithValue("@FilePath", strSavePath)

    如有output, 需要Direction = ParameterDirection.Outputs.

    2010年4月2日 3:19