Hi may i ask how to Get value from database display in textbox?I had a table name mttuser.When i login it will automatic show me the personal informaion.
here is my code

private void Process_Load(object sender, EventArgs e)
        {
            gent_login frm_login = new gent_login();

            using (Mttuser_DAL dalObj = new Mttuser_DAL())
            {
                if (frm_login.txt_proximity.Text != null)
                {
                    try
                    {
                        Mttuser row = new Mttuser();
                        row.us_UserID = txt_id.Text;
                        row.us_EmpName = txt_name.Text;
                        dalObj.GetRecords().Cast<Mttuser>().ToList();
                    }

                    catch (Exception es)
                    {
                        MessageBox.Show(es.Message);
                    }
                }
            }
        }

I had try it but it still no display any information that store in database.It is not using mysql or sql query because it had the connect code behind the code.

Hello Yuki:
Just based on the code you presented here it looks like you're trying to assign what's in the TextBoxes to the columns in your database. Take a look at your code again and see if you can spot the error.

Hint: If you want to assign a value to your TextBox, what would you have to do? :)

Tekkno

MySqlConnection c = new MySqlConnection("your connection, username, password, port");
MySqlDataAdapter d = new MySqlDataAdapter();
string q;
DataTable t;

//here's the code for getting the data for mysql.
q = "Select * from YOURTABLE";
t = new DataTable();
d.SelectCommand = new MySqlCommand(q, c);
d.Fill(t);
if(t.Rows.Count > 0)
{
    TextBox1.Text = t.Rows[0][0].ToString();//you will get the first data in your query result
}

just change the MySql to Sql if your are using Sql.

Happy Coding.

Jerrime Glori. :)
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.