Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
cmd3.CommandText = "UPDATE Seats SET SeatStatus = 'Y' WHERE (FlightId =('" + flightf + "') AND SeatName =('" + DropDownList4.SelectedValue + "'))";


thanks for helping

the problem is
DropDownList4.SelectedValue
:

when i do it like this its work:
C#
string ss = "Y";
string sn =  "C07";
cmd3.CommandText = "UPDATE Seats SET SeatStatus = ('" + ss + "') WHERE FlightId =('" + flightf + "') AND SeatName =('" + sn + "')";


so the problem in the value

i try this:

string sn = Convert.ToString(DropDownList4.SelectedValue);

not worked
Posted
Updated 30-Aug-13 3:38am
v2
Comments
Aiham85 30-Aug-13 5:53am    
i change it like this:

cmd3.CommandText = "UPDATE Seats SET SeatStatus = 'Y' WHERE FlightId = ('" + flightf + "') AND SeatName = ('" + DropDownList4.SelectedValue + "')";

not working
Nelek 30-Aug-13 5:55am    
Have you tried to compile it and / or to debug it?
[no name] 30-Aug-13 5:56am    
Is FlightId really a string? Is flightf empty? Is there anything selected in DropDownList4? Is the selected value of DropDownList4 really a string? Is your connection string correct? Is your connection open? Did you execute your query? Are you getting the feeling that your "question" is way too vague yet? Did you debug your code?
Herman<T>.Instance 30-Aug-13 5:58am    
that are indeed the only things to check!
phil.o 30-Aug-13 6:21am    
I wish I could vote 5 to this one ;)

The main error is you are constructing a SQL query by concatenating string input from user.
This is prone to SQL injection attacks.
Better use parameterized query.

Other error could be a problem with the selected value of your DropDownList (for example, it contains the character '). It's just a guess with the little information you are providing.
 
Share this answer
 
Comments
Herman<T>.Instance 30-Aug-13 5:59am    
pointing out preventing SQL injections is Always my 5!
phil.o 30-Aug-13 6:02am    
Thanks :)
C#
cmd3.CommandText = "UPDATE Seats SET SeatStatus = 'Y' WHERE FlightId ='" + flightf + "' AND SeatName ='" + DropDownList4.SelectedValue + "'";
 
Share this answer
 
v2
Comments
Herman<T>.Instance 30-Aug-13 7:15am    
use String.Format like:
cmd3.CommandText = string.Format("UPDATE Seats SET SeatStatus = 'Y' WHERE FlightId ='{0}' AND SeatName ='{1}'", flightf, DropDownList4.SelectedValue ) ;
Makes it all more readable
I feel that the dropdownlist is not returning the value due to which you are getting the error. So, make it sure that you are getting some value against DropDownList4.SelectedValue; if you don't get some value you can try getting value by using DropDownList4.Text or DropDownList4.SelectedItem.
 
Share this answer
 
It maosi has no fault,please remove '+',and retry
 
Share this answer
 

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