please send early RRS feed

  • Question

  • If MyTextBox.Text=String.Empty



         MyValueParam.Value = Convert.ToInt32(MyTextBox.Text)

    End if

    what is the meaning of MyValueParam


    Saturday, October 1, 2011 2:04 PM

All replies

  • If you are dealing with a parameterized query such as

    cmd.CommandText = "INSERT INTO [Sheet1$] (Identifier,FirstName,LastName) VALUES (@Identifier,@FirstName, @LastName)"
    cmd.Parameters.AddWithValue("@Identifier", CurrentID)
    cmd.Parameters.AddWithValue("@FirstName", txtFirstName.Text)
    cmd.Parameters.AddWithValue("@LastName", txtLastName.Text)
    cmd.Parameters(0).Value = "Another first name"
    cmd.Parameters(1).Value = "Another last name"

    Then Value is the string value (in the case of the above example) to use in the query. The Value is of type Object so what you place into Value should be the same type as the column you are working with i.e. if the column is an integer

    Dim Index as Integer = 3
    cmd.Parameters(Index).Value = 10


    Saturday, October 1, 2011 2:39 PM
  • Hi,
    It seems "MyValueParam" has been declared as SQLParameter type.
    It is another way to pass value to stored procedure.

    • Edited by Shkumar Saturday, October 1, 2011 3:21 PM
    Saturday, October 1, 2011 3:21 PM