I'm new developing and I need a detailed answered, I'm sorry for my bad english... I will try to explain myself the best I can.. I've 2 tables in Mysql
table1: id_ticket , ticket_description, ticket_status(id_status)
table2 : id_statu , status_name
In my application I use all the information inside table1 to fill a DataGridView, also I've added a comboBox column, the combobox displays "status_name" from table2, I want to modify ticket_status with the information contained in the comboBox, how can I do that?
this is my code:
public void CreateAssignedToMe(string ConnString)
{
string assignedTo = textBoxUid.Text;
string query = "SELECT * FROM reports WHERE ticket_assignee='"+assignedTo+"' AND ticket_resolution < 3;";
AssignToMe = new AssignedToMe();
AssignToMe.ConnString = ConnString;
DataGridView dgvReports = AssignToMe.dataGridViewAssignedToMe;
try
{
MySqlConnection conn = new MySqlConnection(ConnString);
conn.Open();
MySqlDataAdapter daUsers = new MySqlDataAdapter(query,ConnString);
DataSet dsUsers = new DataSet();
daUsers.Fill(dsUsers,"report");
dgvReports.DataSource = dsUsers;
dgvReports.DataMember = "report";
dgvReports.AllowUserToAddRows = false;
dgvReports.AllowUserToDeleteRows = false;
dgvReports.Columns["ticket_departmentResponsive"].Visible = false;
dgvReports.Columns["ticket_assignee"].Visible = false;
string queryStatus = "SELECT * FROM status";
MySqlDataAdapter daStatus = new MySqlDataAdapter(queryStatus, ConnString);
DataSet dsStatus = new DataSet();
MySqlCommandBuilder builder = new MySqlCommandBuilder(daStatus);
daStatus.Fill(dsStatus, "Resolution");
daStatus.UpdateCommand = builder.GetUpdateCommand();
DataGridViewComboBoxColumn cbbox = new DataGridViewComboBoxColumn();
BindingSource StatusBindingSource = new BindingSource();
StatusBindingSource.DataSource = dsStatus;
StatusBindingSource.DataMember = "Resolution";
cbbox.HeaderText = "Resolution";
cbbox.DropDownWidth = 90;
cbbox.DataSource = StatusBindingSource;
cbbox.DisplayMember = "status_name";
dgvReports.Columns.Add(cbbox);
AssignToMe.ShowDialog();
}
catch(MySqlException ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
I'm not able to post Images :(