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.

commented: Thanks +0

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.