title: Database access from within asp.net C# web sitie
body: <p>I have an asp.net web site I'm trying to develop and I have an issue loading data from a database.  It worked fine in a C# WebForm App and I was wondering what i need to do to get it to work correctly in the asp.net project and bind the results to a dropdownlist to be selected from.</p>
  
  <pre><code>try
              {
                  SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder
                  {
                      DataSource = "127.0.0.1",
                      InitialCatalog = "PIIMSDATA",
                      IntegratedSecurity = true
                  };
          SqlConnection cs = new SqlConnection(connectionStringBuilder.ToString());
                  SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Book1 Order by ID", cs);
  
  
                  }
                  System.Data.DataTable dt = new System.Data.DataTable();
                  da.Fill(dt);
  
                  //DropDownList2.DataSource = ds.Tables[0];
                  //DropDownList2.DataTextField = "ID";
                  //DropDownList2.DataValueField = "ID";
                  //DropDownList2.DataBind();
              }
              catch (Exception ex)
              {
                  ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + ex + "');", true);
                  //MessageBox.Show(ex.Message);
              }
          }
  </code></pre>