2
나는 issues updating my database
을 가졌습니다. 나는 customers name, phone, email, their computer details and the services
을 가져갈 신청서를 만들었습니다. 업데이트를 원하지만 일부 문제가 있습니다. 데이터베이스에 데이터를 삽입하는 방법은 다음과 같습니다.C# SQL 데이터베이스 업데이트
private void btnCreate_Click(object sender, EventArgs e)
{
//string connString = "server=localhost;uid=*****;password=********;database=dbomonkworksinfo;";
MySqlConnection conn = new MySqlConnection("server=localhost;uid=******;password=********;database=dbomonkworksinfo;");
conn.Open();
try
{
MySqlCommand command = new MySqlCommand("Insert into tserviceinfo (First_Name, Last_Name, Date, Phone, Email, Tech, Brand, Model, OS, Type, PC_Issue) values (?First_Name, ?Last_Name, ?Date, ?Phone, ?Email, ?Tech, ?Brand, ?Model, ?OS, ?Type, ?PC_Issue)", conn);
command.Parameters.AddWithValue("?First_Name", tbFirstName.Text);
command.Parameters.AddWithValue("?Last_Name", tbLastName.Text);
command.Parameters.AddWithValue("?Date", tbDate.Text);
command.Parameters.AddWithValue("?Phone", tbPhone.Text);
command.Parameters.AddWithValue("?Email", tbEmail.Text);
command.Parameters.AddWithValue("?Tech", tbTech.Text);
command.Parameters.AddWithValue("?Brand", tbBrand.Text);
command.Parameters.AddWithValue("?Model", tbModel.Text);
command.Parameters.AddWithValue("?OS", tbOS.Text);
command.Parameters.AddWithValue("?PC_Issue", tbIssue.Text);
command.Parameters.AddWithValue("?Services", lvOrdered.Items);
if (rbDesktop.Checked)
{
command.Parameters.AddWithValue("?Type", "Desktop");
}
else if (rbNotebook.Checked)
{
command.Parameters.AddWithValue("?Type", "Notebook");
}
/** MySqlCommand command2 = new MySqlCommand("Insert into tpcinfo (Brand, Model, OS, PC_Issue, Services) values (?Brand, ?Model, ?OS, ?PC_Issue, ?Services)", conn);
command2.Parameters.AddWithValue("?Brand", tbBrand.Text);
command2.Parameters.AddWithValue("?Model", tbModel.Text);
command2.Parameters.AddWithValue("?OS", tbOS.Text);
command2.Parameters.AddWithValue("?PC_Issue", tbIssue.Text);
command2.Parameters.AddWithValue("?Services", lvOrdered.Items);
* Changed to only one table. No one besides me sees the behind the program.
* **/
//command2.Parameters.AddWithValue("?type", SqlDbType.NVarChar).Value = type;
command.ExecuteNonQuery();
conn.Close();
tbFirstName.Clear();
tbLastName.Clear();
tbDate.Clear();
tbEmail.Clear();
tbBrand.Clear();
tbIssue.Clear();
tbTech.Clear();
tbModel.Clear();
tbPhone.Clear();
tbOS.Clear();
lvOrdered.Items.Clear();
lblPrice.Text = "$0.00";
}
catch (MySqlException ex)
{
MessageBox.Show("Can't connect to database\n" + ex.ToString());
}
}
내 질문은 내가 온라인 보았다 how would I write an update statement?
, 정말,하지만 난 내 요구에 아무것도 적응할 수 없었다 나는 빈 그리기입니다. 나는이 프로그램을 매우 일정하게 작업하고 있었지만 몇 달 동안 친절하게 멈추어 버렸고 지금 나는 정말로 공백을 그리고있다. 어떤 도움이라도 대단히 감사하겠습니다! 입력 된 데이터를 볼 수 있지만 지금은 다음 단계로 업데이트됩니다! 감사!