Can't make MYSQL 5 work with ASP.NET 2.0 using GridView

O

onearth

Hello
I managed to use SQL EXPRESS easily, however with MySql 5 or 4 I can't
find any document explainning me how to use it :(

The error i get is: The IListSource does not contain any data sources.
on the line GridView1.DataBind();

I guess i missed using SQLDataSource Control... i do not know what to
do with it to make it work with MySql.

What i did:

using MySql.Data.MySqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String queryString = "select * from mytest";
DataSet ds = GetData(queryString);
GridView1.DataSource = ds;
GridView1.DataBind();
}
DataSet GetData(String queryString)
{

try
{
DataSet ds = new DataSet();
// Connect to the database and run the query.
MySqlConnection conn = new
MySqlConnection("server=localhost; user id=root; password=blabla;
database=test2; pooling=false;");
MySqlDataAdapter adapter = new
MySqlDataAdapter(queryString, conn);

// Fill the DataSet.
adapter.Fill(ds);

}
catch (Exception ex)
{

// The connection failed. Display an error message.
Message.Text = "Unable to connect to the database.";

}

return ds;

}

}



Regards,
onear
and hope someone knows what to do..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top