Hi Guys,
While i managed to add rows and save them in the grid. I want to know the syntax for Update the data in the grid directly.

Thanks

Sai

 private void btnUpdate_Click(object sender, EventArgs e)
        {


            string col2 = dg[1, dg.CurrentCell.RowIndex].Selected.ToString();
            string col3 = dg[2, dg.CurrentCell.RowIndex].Value.ToString();
            string col4 = dg[3, dg.CurrentCell.RowIndex].Value.ToString();
            string col5 = dg[4, dg.CurrentCell.RowIndex].Value.ToString();
            string col6 = dg[5, dg.CurrentCell.RowIndex].Value.ToString();
            string col7 = dg[6, dg.CurrentCell.RowIndex].Value.ToString();
            string col8 = dg[7, dg.CurrentCell.RowIndex].Value.ToString();
            string col9 = dg[8, dg.CurrentCell.RowIndex].Value.ToString();


            string update_sql = "UPDATE Customers SET Last_Name ='"  col2 "'",Type_Of_Trip ='" col3 "', Leaving_From ='" col4 "', Going_To ='" col5 "',Departing_Date ='"col6 "', Returning_Date ='" col7 "', Departing_Time ='" col8 "',Returning_Time ='"col9 "';  // Is this the correct syntax? 
            this.getcom(update_sql);

        }
string update_sql = "UPDATE Customers SET Last_Name = '" + col2 + "', Type_Of_Trip = '" + col3 + "', Leaving_From = '" + col4 + "', Going_To = '" + col5 + "', Departing_Date = '" + col6 + "', Returning_Date = '" + col7 + "', Departing_Time = '" + col8 + "', Returning_Time = '" + col9 + "';"

Is the correct formatting of that SQL statement.

Edited 4 Years Ago by Mike Askew

Comments
Thanks

Got it Thanks. I need one more help. I want to enable the search button as soon as i start typing in the First_Name Text Box. Should i set Search Button property "Enable = false". I want the enable property to be true as soon as i start typing. How to Achieve that? Thanks
Sai

Umm you can use the First_Name.TextChanged event and check if the length of the textbox string is over 0, if so enabling the search button, else disabling it.

This article has been dead for over six months. Start a new discussion instead.