Did or did not Saul know who David was?
1 Samuel 16:19-23 and 1 Samuel 17:55-58
Several possible explanations exist to explain this problem ranging from textual error to the method of the ancient writers to write about themes and then come back to fill in the gaps later. I think the best explanation can be found by looking at the context.
There is no contradiction. Saul was imply asking David whose son he was. He knew David but probably didn't know who was David's father. Since David has just saved Israel, Saul wanted to know who his father was, probably to show the father proper respect for his son David.
In 1 Samuel 16, the Spirit of the Lord had left Saul (16:14) and an evil spirit came and afflicted Saul (16:23). David came and then played for Saul to sooth him. Chapter 17 begins the well known story of David and Goliath with no mention of how much time passes between David playing the harp and Goliath's challenge. It may very well have been many months or even years. Nevertheless, David was the youngest of the sons of Jesse (17:14), who was a youth (17:33), and who tended the flocks (17:15). David is then known as a young musician and a sheep herder, not a warrior as were his three oldest brothers (17:13-14). Saul and David have conversations about David doing battle with Goliath and Saul offers David his armor (17:38). David refuses the armor and goes out to kill Goliath. Saul then asks Abner, "Whose son is this young man?" And Abner said, "By your life, O king, I do not know," (17:55). In verse 58 Saul says, "Whose son are you, young man?" And David answered, "I am the son of your servant Jesse the Bethlehemite."