nothing happens in update table when it executes...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarvanhsr
    New Member
    • Jan 2010
    • 8

    #1

    nothing happens in update table when it executes...

    Code:
        SqlConnection myConn = new SqlConnection();
    
                myConn.ConnectionString = "Data Source=192.168.15.252;Initial Catalog=TestDB;User ID=sa;Password=Pdindia123;";
    
                myConn.Open();
    
                string strqry = "UPDATE Registration SET  Password = ' " + Text2.Text + " ',PhoneNo = ' " + Text3.Text + " ', Email = '" + Text4.Text + "' WHERE (UserName = ' " + Text1.Text + " ')";
    
    
                Response.Write("UPDATE Registration SET  Password = ' " + Text2.Text + " ',PhoneNo = ' " + Text3.Text + " ', Email = '" + Text4.Text + "' WHERE (UserName = ' " + Text1.Text + " ')");
    
                Label1.Text = Text3.Text;
    
                SqlCommand myCom = new SqlCommand(strqry, myConn);
    
               myCom.ExecuteNonQuery();
    
                myConn.Close();

    No error, not Updating table... simply remains same.....

    The update statement is not working in my website, no error in C# and no error in sql server. When I paste the update query into the sql query tool and replace the parameter values (+...) with real values, it updates the record.
    Last edited by Frinavale; Feb 12 '10, 02:14 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Dear sarvanhsr,

    Try to implement exception handling [try...catch] :)

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Please take a look at the .NET articles:

      How to use a database in your program part I

      How to use a database in your program part II

      Notice how in part I that parameters are used to create the SQL query. I recommend that you give that at try and see if it fixes the problem.

      -Frinny
      Last edited by Niheel; Jul 10 '12, 09:15 AM. Reason: @frinavale, testing why urls were getting modified when used in combination with list

      Comment

      Working...