誰かが私が間違っていることを教えてもらえますか? ページの読み込み時にメソッドを自動的に呼び出そうとしていますが、機能しません。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
customerInformation();
}
}
protected void ddNames_SelectedIndexChanged(object sender, EventArgs e)
{
customerInformation();
}
private void customerInformation()
{
string dbString = ConfigurationManager.ConnectionStrings["TechSupportDBConString"].ConnectionString;
string query = "SELECT * FROM Customers WHERE Name='" + ddNames.Text + "'";
SqlConnection Connection = new SqlConnection(dbString);
Connection.Open();
SqlCommand Com = new SqlCommand(query, Connection);
SqlDataReader reader = Com.ExecuteReader();
if (reader.Read())
{
lblName.Text = reader["Name"].ToString() + "'s Personal Information";
lblAddress.Text = reader["Address"].ToString() + "\n" + reader["City"].ToString() + " " + reader["State"].ToString() + " " + reader["ZipCode"].ToString();
lblPhone.Text = reader["Phone"].ToString();
lblEmail.Text = reader["Email"].ToString();
reader.Close();
Connection.Close();
}
}