John Halliday2 on Wed, 27 Apr 2016 18:33:45

Hi all,

I have one VS2013 project with this code:

     Dim sqlCon As SqlConnection = New SqlConnection(GetConfiguredAppValue("Conn", ""))
     Dim cmd As SqlCommand = New SqlCommand("UploadFile", sqlCon)
     cmd.CommandType = CommandType.StoredProcedure

     cmd.Parameters.Add("@pathname", SqlDbType.VarChar, 500)
     cmd.Parameters("@pathname").Value = "C\temp\uploadfile.txt"


Everything runs fine in the project; the stored proc runs fine - no errors.  However, when I take the same code and place it in another similar project (VS 2013 VB.Net WinApp) and the ExecuteNonQuery is reached, I get:


    Overload resolution failed because no accessible 'Item' accepts this number of arguments."

By viewing the cmd.Parameters value, I see there is one parameter but it is not initialized/has no value.  I have checked the connection, the DB object being called, the parameter spelling and ensured the file specified exists.  In fact, if you drill down in the cmd.Parameters.Item properties you can see:

   In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. System.Data.SqlClient.SqlParameter

Can anyone say why the parameter is not being accepted as part of the command object?

Thanks, JH



Sam Zha on Thu, 28 Apr 2016 10:46:30

Hi John,

How can I reproduce this issue? I've made a simple test, but it works fine. Have you tried rebuilding project and solution?