button的click事件获取textbox内容一直为空
源码:
数据库:
private static string ConnString = "数据库连接字符串";
private static void PrepareCommand(OleDbConnection conn, OleDbCommand cmd, string cmdText)
{
if (conn.State != ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = cmdText;
}
public static int GetSearch(string strSQL)
{
using (OleDbConnection conn = new OleDbConnection(ConnString))
{
OleDbCommand cmd = new OleDbCommand();
PrepareCommand(conn, cmd, strSQL);
return cmd.ExecuteNonQuery();
}
}
protected void ButtonModify_Click(object sender, EventArgs e)
{
string strSQL = "update 表名 set 列名1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:") + "00',列名2='" + TextBoxText.Text + "' where 列名3 = '" + strKey + "'";
GetSearch(strSQL);
Response.Redirect(Request.Url.ToString());
}