I'm trying to populate a dropdown list control. 'Inputs' is the DB. Table is 'ApplicationName', and it has a random value assigned to it.
For some reason, when I click the Test Submit button, nothing is appearing in the control (DropDownList1).
protected void TestSubmit_ServerClick(object sender, EventArgs e)
{
// Initialize the database connector.
SqlConnection connectSQL = new SqlConnection();
// Send the connection string.
connectSQL.ConnectionString = @"Data Source = localhost\SQLEXPRESS;" +
"Initial Catalog = Inputs; Integrated Security = SSPI";
try
{
// Setup our command.
SqlCommand theCommand = new SqlCommand("SELECT * FROM Inputs", connectSQL);
// Write the stored value in the text boxes.
connectSQL.Open();
SqlDataReader theReader;
theReader = theCommand.ExecuteReader();
theReader.Read();
DropDownList1.Items.Add(theReader["ApplicationName"].ToString());
theReader.Close();
connectSQL.Close();
}
catch (Exception ee)
{
MessageBox("Oopsie: " + ee);
}