iam new in C#, am creating a website using asp.net but i am facing some problem. the problem is this i want to a web application that can retrieve data from mysql database and display the data in textboxes. the concept is this i want a client type his/her username inside a textbox and click send button the client will be redirected to another webpage where he can see the scores he has in all his subjects in those textboxes. i dont want to use gridview
please any ideal on how to write the codes
thanks

What have you got so far in terms of code?

First of all, you'll need a MySql connector for your project Click Here, or you can import it (if using VS) by managing NuGet packages.
After that you'll need to have some sort of access to the database, like this:

string connStr = String.Format("server={0};user id={1}; password={2};" +
    "database=your_database; pooling=false", "server_ip",
    "user", "pass");

Getting the information is fairly simple:

string query = "your MySql query";
using (MySqlConnection con = new MySqlConnection(connStr))
{
    using (MySqlCommand cmd = new MySqlCommand(query, con))
    {
        con.Open(); //don't forget to open the connection
        var rdr = cmd.ExecuteReader();
        rdr.Read();
        //do something with the values returned from your query
    }
}

If you want to display information (scores) when you redirect your client to the other page, you can send as a GET/POST request your client info, so that you'll know what to search for. Let's say for example, that your redirect page has two fields:

<input id="Element_Value_Field" type="text" runat="server"/>
<input id="Element_ExtraInfo_Field" type="text" runat="server"/>

where Element_Value_Field will be the client's name, and Element_ExtraInfo_Field will be his score. Let's also suppose that your redirect page receives a GET request with the parameter element (which will be your client's name/identification). When you load the page, you can do like this:

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["element"] != null)
    {
        string RequestedElement = Request.QueryString["element"];
        Element item = (new Get()).ElementBy(RequestedElement); //make your query for the requested element
        Element_Value_Field.Value = item.Value;        //input-box from your page
        Element_ExtraInfo_Field.Value = item.ExtraInfo;//input-box from your page
    }
}

where Element is a class to store your score information.
After your query is complete, you just set your text-box values to those returned from the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.