void Page_Load(Object Src, EventArgs E)
{
string SQL = "SELECT top 1 * FROM password WHERE bhh IS NULL";//找到 bhh爲空的第一個記錄
SqlConnection Conn;
Conn = new SqlConnection("連接數據庫");
Conn.Open();
//Response.Write(SQL);
SqlCommand Comm=new SqlCommand(SQL,Conn);
SqlDataReader dr=Comm.ExecuteReader();
if (dr.Read())
{Label1.Text=dr["xxx"].ToString();
Label2.Text=dr["yyy"].ToString();
Label3.Text=dr["zzz"].ToString();
Conn.Close();
}
else
{
Conn.Close();
Response.Redirect("bhend.ASPX?");//如果沒有符合要求的記錄則跳出
}
}
void ONButton1Click(Object sender, EventArgs e) //單擊保存並處理下一條按鈕
{
string user = Label1.Text;
SqlConnection Conn1;
Conn1 = new SqlConnection("連接數據庫");
string SQL1= "UPDATE Password SET bhh = ";
SQL1 = SQL1 + "'"+ TextBox1.Text +"'where name ='"+user+"'";
SqlCommand Comm1=new SqlCommand(SQL1,Conn1);
Conn1.Open();
Comm1.ExecuteNonQuery();
Conn1.Close();
TextBox1.Text="";
Response.Redirect("bhgl.ASPX?");//刷新頁面
}