I am fully new in the programming section so don't try bad help pls.
Actually I am fail focus data from phpmyadmin to c# windows form textbox1.Text area.
My database name: business, Table Name: life, columns Name : Email_id
I need to show email id 10 number row in my textbox1.Text area.
See my code
string connString = "datasource=x5x.1x1.13x.xxx;Database=business;username=sumon;password=root";
MySqlConnection connect = new MySqlConnection(connString);
MySqlCommand myCommand = connect.CreateCommand();
string input = textBox1.Text;
myCommand.CommandText = "SELECT * FROM life WHERE id = @input";
connect.Open();
MySqlDataReader reader = myCommand.ExecuteReader();
if (reader.Read())
textBox1.Text = reader["*"].ToString();
connect.Close();
Talk1:
What's your problem?
Solutions1
you've missed to set the value for @input. I edited you code (without testing). Give it a try.
string connString = "datasource=x5x.1x1.13x.xxx;Database=business;username=sumon;password=root";
MySqlConnection connect = new MySqlConnection(connString);
MySqlCommand myCommand = connect.CreateCommand();
myCommand.Parameters.Add(new SqlParameter("input", 10));
//string input = textBox1.Text;
myCommand.CommandText = "SELECT * FROM life WHERE id = @input";
connect.Open();
MySqlDataReader reader = myCommand.ExecuteReader();
if (reader.Read())
textBox1.Text = reader["Email_id"].ToString();
connect.Close();