Hey, As you can see i have a function to retrieve the product description based on product code. For some reason this is refusing to return a value even though the value im entering into test is there in the table, i can see the value of the input enters fine, but by the end the string is empty.

Plsssss help looked at the same code for 3 days now lol

Private Function GetProductFromProductTable(ByVal product As String) As String
        Dim productDescription As String = String.Empty

        Using Myconnection As New SqlConnection()

            Myconnection.ConnectionString = ConfigurationManager.ConnectionStrings("EDIconnectionString").ConnectionString

            Dim mycommand As New SqlCommand()
            mycommand.Connection = Myconnection
            mycommand.CommandText = "SELECT Long_description FROM Stock WHERE Product = @Product"
            mycommand.Parameters.AddWithValue("@Product", product)

            Myconnection.Open()

            Dim dr2 As SqlDataReader = Nothing
            dr2 = mycommand.ExecuteReader()
            dr2.Read()
            While dr2.Read()
                productDescription = Convert.ToString(dr2("Long_description"))
            End While

            dr2.Close()

            Myconnection.Close()


            Return productDescription
        End Using
    End Function

Apologies if this is well off base, but what datatype is Product in your table? If its a char field of some description, shouldn't it's value be wrapped in single quotes in your SQL?

It looks like you are calling Read() two times.

Dim dr2 As SqlDataReader = Nothing
dr2 = mycommand.ExecuteReader()
dr2.Read()
While dr2.Read()
productDescription = Convert.ToString(dr2("Long_description"))
End While

Edit: When I call data I always check to see if my reader has rows before I use it. Here is how I do it in C#

if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    ......
                }
            }