I have a difficulty, I have code that allows to capture all information from the datagridview and send in the database. Whenever I have execute the code it replicates in the database, and I do not know how to do it.
public void GetAllUserID() { SqlConnection con = new System.Data.SqlClient.SqlConnection(); con = new System.Data.SqlClient.SqlConnection(); //con.ConnectionString = ""; con.ConnectionString = @"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBTESTE;Data Source=PD\PRIMAVERA"; con.Open(); SqlDataAdapter da = new SqlDataAdapter(); for (int i = 0; i <= dgvRecords.Rows.Count - 1; i++) { string insertData = "insert into tbAlluserid (MachineNumber, EnrollNumber, BackupNumber) values (@MachineNumber, @EnrollNumber, @BackupNumber)"; SqlCommand cmd = new SqlCommand(insertData, con); cmd.Parameters.AddWithValue("@MachineNumber", dgvRecords.Rows[i].Cells[0].Value); cmd.Parameters.AddWithValue("@EnrollNumber", dgvRecords.Rows[i].Cells[1].Value); cmd.Parameters.AddWithValue("@BackupNumber", dgvRecords.Rows[i].Cells[2].Value); da.InsertCommand = cmd; cmd.ExecuteNonQuery(); } }
I tried, the method that allows deleting the table, but not the desired one
You can update but I thought, because for some reason the datagridview shows some null fields, this can influence the results in the database.
Or what do you suggest?
Note the information shown in the datagridview is being viewed from the biometric.
Many thanks sirs, I did, but was forced to create a procedures to update the registry in the database.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)