0
안녕하세요, 저는이 언어 C# 및 MySQL에서 새롭게 출시되었습니다. In
및 Unit_Value
의 값이 아직 0
인 이유를 알지 못합니다.
열을 업데이트하고 항목을 추가 할 때마다 해당 항목의 수량을 현재 값에 추가해야합니다.테이블 업데이트
이것은 내가하고자하는 것입니다 : = (수량 * Unit_Value)이며 현재 값에 추가되어야합니다. Unit_Value = textBox3.Text (Unit_Value는 콤보 상자에있는 데이터베이스의 고정 값이므로 콤보 상자의 selecteditem 이름으로 얻습니다).
string constring1 = "datasource=localhost;port=;username=;password=;database=;";
MySqlConnection conDataBase1 = new MySqlConnection(constring1);
MySqlCommand mycommand = new MySqlCommand("select `Unit_Value` from `tbl_inventory_item_unit` where `Unit_Name`='"+metroComboBox2.Text+"';",conDataBase1);
MySqlCommand myincommand = new MySqlCommand (
"UPDATE `tbl_inventory_in` SET `In`= `In` + '" + metroLabel12.Text +
"',`In_Quantity`='" + textBox3.Text +
"',`Unit_Value`='" + metroLabel11.Text +
"',`Unit_Name`='"+ metroComboBox2.Text +
"',`In_Date`='"+ metroLabel8.Text +
"'where `Item_ID`='" + textBox4.Text +
"';",conDataBase1);
string b;
int c;
int a;
try {
conDataBase1.Open();
MySqlDataReader myReader1 = mycommand.ExecuteReader();
while (myReader1.Read()) {
b = myReader1.GetValue(0).ToString();
// c = Int32.Parse(b);
// c = Convert.ToInt32(c);
c = Int32.Parse(b);
a = Int32.Parse(textBox3.Text);
metroLabel11.Text = c.ToString();
metroLabel12.Text = (a * c).ToString();
}
myReader1.Close();
MySqlDataReader myinreader = myincommand.ExecuteReader();
while (myinreader.Read()) {
}
MessageBox.Show("Stocks Added");
conDataBase1.Close();
}
포맷이 완전히 통해 오지 않았다을 ... –
은 읽어 보시기 바랍니다 이 대답과 연결된 기사. 위의 코드가 현재 취약한 SQL 주입 공격을 피하는 방법을 설명합니다. http://stackoverflow.com/a/14376963/1991296 –