0

Below is my code

Dim myCmd As SqlCommand
myCmd = New SqlCommand("Update tbl SET Name = @Name, Age=@Age where Id=3", GetConnection())
myCmd.Parameters.AddWithValue("@Name", "Charles")
myCmd.Parameters.AddWithValue("@Age", 55)

After few lines I want to read the Parameter Value that is assigned, but I am getting error

Dim str as string = myCmd.Parameters("@Name").Value

Error is

Message: Overload resolution failed because no accessible 'Parameters' accepts this number of arguments. DEBUG MODE

Please help to resolve the issue

captainsac
  • 2,484
  • 3
  • 27
  • 48
  • Can you add a screenshot of the code, halted with that exception helper open? The only thing that looks wrong to me is that Value returns object so will need casting or tostring(). I'd like to see if there is something else around the code that could be relevant – Caius Jard Sep 20 '19 at 06:35
  • I have to agree with @CaiusJard. With `Option Strict Off` (which it should not be) your code compiles without issue for me. There must be something else going on. If you type a dot after `myCmd` does Intellisense show `Parameters` as an option? What type is it? – jmcilhinney Sep 20 '19 at 07:37
  • Exact code is at https://stackoverflow.com/questions/58009959/overload-resolution-failed-because-no-accessible-parameters-accepts-this-numbe?noredirect=1#comment102448759_58009959. ArrayList is filled with SQLCommand objects – captainsac Sep 20 '19 at 08:44

0 Answers0