0

I have a students table, a courses table and a student/courses table to show the students enrolled in a course. The table is in SQL Server 2008 and the front end in C# and Asp.net.

In the student/courses table I would like to be able to have a dropdown menu that will allow me to select the student ID stored on the database and then populate the student's name, last name and middle initial in a textbox or label.

How can I possibly do this? Any examples? Thank you for your help!

6
  • 1
    users table is same as the student table?? Commented Apr 12, 2013 at 23:07
  • Start with ADO.NET. Commented Apr 12, 2013 at 23:10
  • @PraveenNambiar my bad, it is supposed to be the same. I made the change. Thanks! Commented Apr 12, 2013 at 23:19
  • @Brian I'm not very familiar with ADO.NET. How does it work? Commented Apr 12, 2013 at 23:21
  • 1
    @ElianaLopezSanchez - That is a very large question you have asked... Basically, it is a means for you to be able to 'talk' to and manipulate a database via code (like C#, VB and the like). In my comment above, ADO.NET is hyperlinked to take you to the documentation/getting started page for it. Commented Apr 12, 2013 at 23:26

1 Answer 1

1

You can use either ADO.net, if not familiar then

on page load event

 SqlCommand cmd = new SqlCommand();
    cmd.Connection= new Class1().getconnection();
    cmd.CommandText = "SELECT * FROM Profile";
    cmd.Connection.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    while (dr.Read())
    {
        DropDownList1.Items.Add(dr["YahooId"].ToString());
    }

in "cmd.CommandText" instead of "Profile" use your table name, and under "while(dr.read()) use your column name instead of "YahooId"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.