Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my update query.

I am not getting any errors but the values are not being updated into the database.


cmd.CommandText = "update registration set name ='" + txtname1.Text + "',email_id='" + txtemail1.Text + "',degree='" + txtdegree1.Text + "',address='" + txtaddress1.Text + "' where employee_id='" + txtemployeeid1.Text + "'";
Posted
Updated 31-Aug-10 3:31am
v2
Comments
DavidKiryazi 25-Aug-10 0:46am    
Might help if you post a bit more code :) Are you using the following command somewhere

cmd.ExecuteNonQuery()
Per Söderlund 25-Aug-10 1:15am    
I can't find anything wrong with your CommandText.
Dalek Dave 31-Aug-10 9:31am    
Edited for Readability.

Try to debug it as follows (Assuming you are using Visual Studio):

1. Set a breakpoint at the following line and run your program in debug mode.

cmd.CommandText = ...


2. When the breakpoint hits this line, view the value of cmd.CommandText (Using watch or Immediate window) and copy the value.

3. Run the SQL in the SQL Server Management Studio (Or, the query window of your database server).

4. See what happens. If it does not run correctly, try to analyze the SQL and find problem. Make sure the SQL is correct.

5. Now, find the difference between the correct SQL and the SQL that you copied from the cmd.CommandText property from the breakpoint. Fix the code that is generating the wrong part of the SQL.

Hopefully, your problem will be solved

Best wishes
 
Share this answer
 
Comments
DavidKiryazi 25-Aug-10 0:47am    
Reason for my vote of 5
Good debugging technique to try and determine the source of the problem by using a known working application, in this case SQL management studio.
Per Söderlund 25-Aug-10 1:13am    
Reason for my vote of 5
It's not a solution to his problem, it's a solution to find the solution.Based on the info we got in the question I think this is the best answer you can get.
Al-Farooque Shubho 25-Aug-10 3:50am    
Thanks mates, for your votes and comments.
Simon_Whale 31-Aug-10 9:48am    
Reason for my vote of 5
thats the best way to debug such an issue
if type of field is number,don't use quotation sign :

"... where employee_id=" + txtEmployeeid1.Text + ""
 
Share this answer
 
Comments
Sandeep Mewara 31-Aug-10 15:31pm    
You could have updated your last answer instead of adding a new one!
In addition to the other comments, are you binding to your data in the prerender event, b/c if you're doing it in your page load, you bind before you update, which would stop the data appearing on screen, first time. Secondly, assuming you resolved this, I hope this application will never be used in the real world, because any malicious user that would want to delete your database, could, due to a lack of security in your code.
 
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