I made this procedure to help me re-use a select query:
Private Sub selectQry(ByVal myColumn As String, ByVal myTable As String, ByVal myFilter As String, ByVal myObjectOne As Object, ByVal myObj As Object)
Dim qrySlctCaldate As String = "SELECT " + myColumn + " FROM " + myTable + " WHERE " + myFilter + " = '" & Replace(myObjectOne, "'", "''") & "'"
Dim cmdSlct As New SqlCommand(qrySlctCaldate, transConn.Connection)
Dim readSCalDate As SqlDataReader
readSCalDate = cmdSlct.ExecuteReader
While readSCalDate.Read
If TypeOf (myObj) Is TextBox Or TypeOf (myObj) Is ComboBox Then
myObj.Text = readSCalDate.Item(myColumn).ToString
Else
myObj = readSCalDate.Item(myColumn).ToString
End If
End While
readSCalDate.Close()
And I use it like this if I would want the selected value placed in a textbox and it works fine
selectQry("ProcConvDescription", "Line", "LineCode", nameValue.Value, txtProcess)
However if I want the value to be passed in a string like so:
selectQry("LastCalibrationDate", "EquipmentItem", "ControlNo", txtControlNo.Text, strCalDate)
The string ends up having an empty string value. How do I assign the value I queried to that String?