【发布时间】:2013-10-28 19:02:49
【问题描述】:
在我的表单应用程序中,我有两个按钮。当用户点击按钮时,它会在 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();
}
【问题讨论】:
-
没有注意到你的问题
-
我想启用我的用户活动登录,例如他在文本框中输入的数字
-
你的意思是“textBox_cNumber”中的值吗?
-
客户在文本框中输入的内容应记录在文本文件中
-
你真的没有一个叫
TableTBL的表吗?