• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

What's wrong with these 3 lines of code? (C#, oleDb, beginner's level)

I am trying to display all shirt descriptions where there is the word "red" in the desc.
Code compiled fine. There is something missing in this sequence that crashes app when I run:


         oleDbDataAdapter1.SelectCommand.CommandText = "SELECT Item_No, Shirt_Desc FROM SHIRTS WHERE Shirt_Desc LIKE %red%";
         dsShirt.Clear();
         oleDbDataAdapter1.Fill(dsShirt);

First I filled out the Select Command then I clear the dsShirt dataset. Finally, I assume that when the adapter's Fill is executed, the select command is automatically carried out. I must be wrong because it doesn't work as intended.

Thanks.
0
rj94070
Asked:
rj94070
1 Solution
 
sweatbeastCommented:
shouldnt %red% be in single quotes - '%red%'?
0
 
rj94070Author Commented:
Brilliant.
Thanks sweatbeast!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now