I attempted to get the records from the MySQL database and display it on a Grid View but nothing appeared. The code is below:
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=mysql;" +
"UID=root;" +
"PASSWORD=bamboboy;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
command.CommandText = "select * from corporate";
connection.Open();
MySqlDataAdapter myadapter = new MySqlDataAdapter(command);
DataSet dts = new DataSet();
myadapter.Fill(dts);
GridView1.DataSource = dts.Tables[0];
connection.Close();
}
protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
}