Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Winforms application


C#
rtxt.Text = "SELECT  Title, Rating, CategoryCode, Description FROM tblMovieTitles WHERE (Rating = '" + this.chklCode.Text + "' ) AND (CategoryCode =";

//Add the value
//Do loop on all selected items
// AND/OR (CategoryCode = lstCategorie[x].value ;

                
rtxt.Text += ")";
   
scmd = new SqlCommand(rtxt.Text, conn);


Do i missing something above.
I have a "Description" column and a "categoryCode" column in a table. I have populated the "Description" in a listbox. what i want is when i click the "Description" in listbox.
The richtextbox should populate the related "categoryCode" of the "Description" value. and the value should be pulled in richtext box.

Ex: My rich text box should appear as..

CategoryCode = ??????????

Please correct my code or add something appropriate.. Please don't give THEORY advise.

[Modified: added pre tags...they are your friend]
Posted
Updated 5-Nov-10 11:05am
v2

1 solution

you know the saying, "you can give a man a fish and he'll eat for a day, but teach him how to fish and he'll be able to eat for life"?

if we just fix your code, then you'll just be right back here the next time you have a problem. Providing you with theory is the best way to answer your question.

But, really, I'm not sure how to answer your question because your question is quite unclear.

But with what you provided us, you don't ever set the category code. So, yes, you missed something...

FYI, if I were you, I would google "SQL injection attack". Because your code is susceptible depending on what type of control chk1Code is.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900