在我的表单应用程序中,我有两个按钮。当用户点击按钮时,它会在 SQL 中更新。
所以我想记录用户在单独的 txt 文件(日志)中用户在表中输入的文本框中输入的数字。
请检查以下代码以了解我的应用程序在做什么
private void button_StatusChange_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("Data source = Test; Initial Catalog = TableName; user id = sa;pwd = 12345678 ");
if (MessageBox.Show("Do you really need to change", "Success", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
this.Close();
SqlCommand updateCommand = sqlcon.CreateCommand();
sqlcon.Open();
updateCommand.CommandText = " update dbo.TableTBL set ColumName = '" + comboBox_statusChange.Text + "' where TId = '" + textBox_cNumber.Text + "'";
string resultStatus = ((string)updateCommand.ExecuteScalar());
updateCommand.ExecuteScalar();
MessageBox.Show(" Status Changed Successfully");
sqlcon.Close();
}