How update data stored in database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rishabh Indianic
    New Member
    • Sep 2009
    • 22

    How update data stored in database?

    hi,

    i am trying to update data stored in data base with following code i am able to show data from database but i can not able to update it.

    Code:
    int Theme_ID = Convert.ToInt32(textBox1.Text);
                string Theme_Name = textBox2.Text;
                SqlCeConnection conn;
            
                string connstr = " Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\MyFirstDataBase.sdf;";Persist Security Info=False;";
                conn = new SqlCeConnection(connstr);
                conn.Open();
               
                SqlCeCommand cmd = new SqlCeCommand();
                cmd.CommandText = "update Theme set Theme_Name=Theme_name where Theme_ID=Theme_ID ";
              
                cmd.Connection = conn;
                cmd.Parameters.AddWithValue("Theme_ID", Theme_ID );
                cmd.Parameters.AddWithValue("Theme_Name", Theme_Name);
              
                cmd.ExecuteNonQuery();
                conn.Close();

    the above code execute well but can not create any change in database.
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    I would assume your SQL is the problem.

    Try it out manually 1st then see if it works

    Comment

    Working...