Click here to Skip to main content
15,890,670 members
Home / Discussions / C#
   

C#

 
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 
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 
Yes I can display my Gridview and edit it. When I click update that is where the issue is?
You told me to cmd.Parameters.Clear(); Should that be in the foreach loop?
C#
protected void gvKeyPersonnel_RowUpdating(object sender, EventArgs e)
        {
            
                    
            using (SqlCommand cmd = new SqlCommand())
            {
               cmd.Connection = conn;
                conn.Open();
                                   
                
                foreach (GridViewRow row in gvKeyPersonnel.Rows)
                                   
                  {

                   cmd.Parameters.Clear(); 
                   
                   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.ExecuteNonQuery();   
                   cmd.Parameters.AddWithValue("@id", row.Cells[0].Text);
                   cmd.Parameters.AddWithValue("@Name", row.Cells[1].Text);
                   cmd.Parameters.AddWithValue("@VDCIDIQ", row.Cells[2].Text);
                   cmd.Parameters.AddWithValue("@VDCFFS", row.Cells[3].Text);
                   cmd.Parameters.AddWithValue("@VDCHIM", row.Cells[4].Text);
                   cmd.Parameters.AddWithValue("@VDCWEBHOSTING", row.Cells[5].Text);
                   cmd.Parameters.AddWithValue("@VDCCWF", row.Cells[6].Text);
                                      
                    
                   
                }
                conn.Close();
            }
        }


I must be missing something here? Thanks for your help and looking at it?
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 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 20:20
professionalAgent__00713-May-15 20:20 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 20:24
Norris Chappell13-May-15 20:24 
GeneralRe: Update in C# using SQL Server Database. Pin
Norris Chappell13-May-15 20:30
Norris Chappell13-May-15 20:30 
GeneralRe: Update in C# using SQL Server Database. Pin
Agent__00713-May-15 20:43
professionalAgent__00713-May-15 20:43 

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.