Home Forums Programming General Updating datagrid with C#.net RE: Updating datagrid with C#.net

  • rayh 98086 (4/16/2013)


    My two questions that I have are:

    1.) How do I put loop here to update all records in data grid????????????????????

    2.) What is the correct syntax to pass an update from data grid to the database?????

    No offense but you are going about this entirely wrong. You don't loop through every row in a grid and update the database. You handle updates when the row is updated by handling the RowUpdating event.

    The best way is to use a stored proc instead of pass through sql to protect against sql injection.

    Do a quick google/bing search for "dot net datagrid update" you will find hundreds if not thousands of examples of how to do this.

    I can help you tomorrow if you get stuck.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/