我是新手,我需要一个详细的答案,对不起我的英语不好......我会尽力解释自己......我在 Mysql 中有 2 个表
table1: id_ticket , ticket_description, ticket_status(id_status)
table2 : id_statu , status_name
在我的应用程序中,我使用 table1 中的所有信息来填充 DataGridView,还添加了一个组合框列,组合框显示 table2 中的“status_name”,我想用组合框中包含的信息修改 ticket_status,我该怎么做那?
这是我的代码:
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());
}
}
我无法发布图片:(