try this...
Private Function GetTableValue(ByVal strVal As String, ByVal sField As String, ByVal sTable As String) As string
Dim drSqlReader As SqlDataReader
Dim SqlCMD As SqlCommand
Dim SqlCN As New SqlConnection(Conn)
Dim strSql As String, sTemp As string =""
Try
If SqlCN.State = ConnectionState.Closed Then SqlCN.Open()
strSql = "SELECT " & sField & " FROM " & sTable & " WHERE User = '" & strVal & "'"
SqlCMD = New SqlCommand(strSql, SqlCN)
drSqlReader = SqlCMD.ExecuteReader()
While drSqlReader.Read
sTemp = drSqlReader.Item(sField)
End While
Catch
sTemp = "error found"
Finally
If Not SqlCN.State = ConnectionState.Closed Then SqlCN.Close()
If Not drSqlReader.IsClosed Then drSqlReader.Close()
If Not SqlCMD Is Nothing Then SqlCMD.Dispose()
End Try
Return sTemp
End Function
'and call it like this...
dim sResults as string = GetTableValue("somename","User", "tmTransactions")
messagebox.show(sResults)