How to populate fields on form from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AustinGal

    How to populate fields on form from database

    I need to populate my textfields from values in database. I also need navigation buttons to scroll through all records, similar to an access form. Below is what I have on the OnLoad event:

    Code:
    protected void Page_Load(object sender, EventArgs e)
            {
    
                SqlConnection conn = new SqlConnection(GetConnectionString());
    
                SqlCommand cmd = new SqlCommand("SELECT * from CriminalHistoryCriteria", conn);
    
                cmd.Connection.Open();           
                cmd.ExecuteReader();
    
                cmd.Connection.Close();
                cmd.Connection.Dispose();
    
            }
    Last edited by MMcCarthy; Oct 28 '10, 11:49 PM. Reason: added code tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Please review the following article about how to use a database.

    It demonstrates how to loop through data that is retrieved from the database and set it to a TextBox's Text property.

    -Frinny

    Comment

    Working...