Click here to Skip to main content
15,891,981 members
Home / Discussions / C#
   

C#

 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon12-May-15 13:45
mvePete O'Hanlon12-May-15 13:45 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell12-May-15 13:51
Norris Chappell12-May-15 13:51 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon12-May-15 19:57
mvePete O'Hanlon12-May-15 19:57 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell12-May-15 20:02
Norris Chappell12-May-15 20:02 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon12-May-15 21:00
mvePete O'Hanlon12-May-15 21:00 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell12-May-15 21:55
Norris Chappell12-May-15 21:55 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon12-May-15 22:17
mvePete O'Hanlon12-May-15 22:17 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 3:48
Norris Chappell13-May-15 3:48 
C#
protected void gvKeyPersonnel_RowUpdating(object sender, EventArgs e)
       {
           int @ID = Convert.ToInt32(gvKeyPersonnel.DataKeys[0].Value.ToString());
           TextBox @Name = (TextBox)gvKeyPersonnel.Rows[0].FindControl("txtName");
           TextBox @VDCIDIQ = (TextBox)gvKeyPersonnel.Rows[1].FindControl("txtVDCIDIQ");
           TextBox @VDCFFS = (TextBox)gvKeyPersonnel.Rows[2].FindControl("txtVDCFFS");
           TextBox @VDCHIM = (TextBox)gvKeyPersonnel.Rows[3].FindControl("txtVDCHIM");
           TextBox @VDCWEBHOSTING = (TextBox)gvKeyPersonnel.Rows[4].FindControl("txtVDCWEBHOSTING");
           TextBox @VDCCWF = (TextBox)gvKeyPersonnel.Rows[5].FindControl("txtVDCCWF");

           using (SqlCommand cmd = new SqlCommand())
           {
              cmd.Connection = conn;
               conn.Open();
               // SqlDataReader myReader = null;
               // myReader = cmd.ExecuteReader();



               foreach (GridViewRow row in gvKeyPersonnel.Rows)
             //    for (int i = 0; i < gvKeyPersonnel.Rows.Count; i++)

                 {



                  cmd.CommandText = @"UPDATE SP2010_EDCStaffing_AppDB.dbo.CMS_Key_Personnel  SET  Name = @Name, VDCIDIQ = @VDCIDIQ, VDCFFS = @VDCFFS, VDCHIM = @VDCHIM, VDCWEBHOSTING = @VDCWEBHOSTING, VDCCWF = @VDCCWF WHERE ID = @id";
                  //cmd.Parameters.AddWithValue("@id", row.Cells[0].Text);
                  //cmd.Parameters.AddWithValue("@Name", row.Cells[0].Text);
                  //cmd.Parameters.AddWithValue("@VDCIDIQ", row.Cells[1].Text);
                  //cmd.Parameters.AddWithValue("@VDCFFS", row.Cells[2].Text);
                  //cmd.Parameters.AddWithValue("@VDCHIM", row.Cells[3].Text);
                  //cmd.Parameters.AddWithValue("@VDCWEBHOSTING", row.Cells[4].Text);
                  //cmd.Parameters.AddWithValue("@VDCCWF", row.Cells[5].Text);
                  cmd.Parameters.AddWithValue("@id", Convert.ToInt32(gvKeyPersonnel.DataKeys[row.RowIndex].Values[0]));
                  cmd.Parameters.AddWithValue("@Name", Name.Text);
                  cmd.Parameters.AddWithValue("@VDCIDIQ", VDCIDIQ.Text);
                  cmd.Parameters.AddWithValue("@VDCFFS", VDCFFS.Text);
                  cmd.Parameters.AddWithValue("@VDCHIM", VDCHIM.Text);
                  cmd.Parameters.AddWithValue("@VDCWEBHOSTING", VDCWEBHOSTING.Text);
                  cmd.Parameters.AddWithValue("@VDCCWF", VDCCWF.Text);

                   cmd.ExecuteNonQuery();
                   cmd.Parameters.Clear();
               }
               conn.Close();
           }

GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon13-May-15 4:11
mvePete O'Hanlon13-May-15 4:11 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 5:17
Norris Chappell13-May-15 5:17 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon13-May-15 5:57
mvePete O'Hanlon13-May-15 5:57 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 6:43
Norris Chappell13-May-15 6:43 
GeneralRe: Update in C# using SQL Server Database. Pin
Pete O'Hanlon13-May-15 7:15
mvePete O'Hanlon13-May-15 7:15 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 8:28
Norris Chappell13-May-15 8:28 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 17:02
professionalAgent__00713-May-15 17:02 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 18:01
Norris Chappell13-May-15 18:01 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 18:11
professionalAgent__00713-May-15 18:11 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 18:21
Norris Chappell13-May-15 18:21 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 18:35
professionalAgent__00713-May-15 18:35 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 19:10
Norris Chappell13-May-15 19:10 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 19:25
Norris Chappell13-May-15 19:25 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 19:26
professionalAgent__00713-May-15 19:26 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 19:53
Norris Chappell13-May-15 19:53 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 20:05
professionalAgent__00713-May-15 20:05 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 20:11
Norris Chappell13-May-15 20:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.