database - DataGridView and Record ID C# -


I think (mine) how SqlDataAdapter works but I need some explanation I have a DGV which I Use a column to display from a MySQL table; However, when I need to edit the records, I mostly require other fields and I do it in another Vanofha. So I think I need some best practices advice:

Question 1: When binding to the data source: I need to have all the fields I want to edit as

  string query = "select * cusdata"; CusAdapter = New MySqlDataAdapter (query, ppdb.sqlConn); CusAdapter.Fill (mainSet, "cusdata"); Dgv_cusData.DataSource = mainSet.Tables ["cusdata"]   

Question 2: I have a lot of information on the web just about choosing the fields you want to display in DGV but if See, I edit the data that the adapter knows which record is being updated on the back-end?

I think I am a bit confused about different approaches and I need some guidance. I need a datagrid view where I can display a single column (the name of the customer). I want to be able to edit the customer records in any other form and after the successful completion of the database operation, the DVG has to refresh with the new information.

I have given the best part today at the end of one week so that any article or blog can be found or which can actually be displayed. Can a list-form paradigm please please me in the right direction? Many thanks for the community

After

With experience you should not select all the areas, rather select only the fields you need ID, CustName, CustAddress, CustPhone Cusdata to

will affect this display.

When you edit a data you can use the following code:

  string connection string = "[insert your connection string here]"; (Using SqlConnection conn = new SqlConnection (connectionString)) {conn.Open (); (SqlCommand cmd = New SqlCommand ("Update Set cusdata CustName = @ CustName, CustAddress = @CustAddress Where CustomerID = @CustomIDID", Connecticut)) {cmd.Parameters.AddWithValue ("@CustomIDID", 1); Cmd.Parameters.AddWithValue ("@CustName", "Name Input"); Cmd.Parameters.AddWithValue ("@CustAddress", "Address Input"); Int rows = CMD.exequintonquine (); // Rows have been updated to record}}   

This part of the code lets you specify fields and data you want to update in your table

 < Code> Cmd.Parameters.AddWithValue ("@CustId", 1); Cmd.Parameters.AddWithValue ("@CustName", "Name Input"); Cmd.Parameters.AddWithValue ("@CustAddress", "Address Input");    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -