I followed the tutorial at 15 seconds on how to set up the database and run a mysql query to get a datagrid like
my question would be is it possible in asp.net to grab say the word Hello out of a mysql query? I've been looking around for tutorials on how to do it all evening and came up with nothing. I'm working on a website and I'd like to make variables with like
a users name, email, ect to put in different places on my page. I think I understand how to pull" hello" out of the query..
My problem is I can only pull it out in an excel like format with the box around it. Is there anyway to make a variable = what is inside that box? Thanks in advance
In this tutorial you are getting a data in object datasource, you can also get data in DataTable from which you can easily read any particular row data.
just simly using page load code of this tutorial
protected void Page_Load(Object sender, EventArgs e)
{
MySqlConnection myConnection = new MySqlConnection(
"server=localhost; user id=15secs; password=password; database=mydatabase; pooling=false;");
String strSQL = "SELECT * FROM mytable;";
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(strSQL, myConnection);
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "mytable");
MySQLDataGrid.DataSource = myDataSet;
MySQLDataGrid.DataBind();
}
In this code you can also get data from myDataSet.
Member
1 Points
3 Posts
setting information
Jun 15, 2010 11:45 PM|kjoe|LINK
I followed the tutorial at 15 seconds on how to set up the database and run a mysql query to get a datagrid like
my question would be is it possible in asp.net to grab say the word Hello out of a mysql query? I've been looking around for tutorials on how to do it all evening and came up with nothing. I'm working on a website and I'd like to make variables with like a users name, email, ect to put in different places on my page. I think I understand how to pull" hello" out of the query..
My problem is I can only pull it out in an excel like format with the box around it. Is there anyway to make a variable = what is inside that box? Thanks in advance
Contributor
2003 Points
685 Posts
Re: setting information
Jun 16, 2010 02:34 AM|Waqar_ali|LINK
I think you have used following tutorial
http://www.15seconds.com/Issue/060317.htm
In this tutorial you are getting a data in object datasource, you can also get data in DataTable from which you can easily read any particular row data.
just simly using page load code of this tutorial
In this code you can also get data from myDataSet.
simply write code
string str = myDataset.Tables[0].Rows[0]["columnName"].ToString();
Please correct me if i understand wrong your problem.
Software Engineer
Please mark as answer if it help you.
Member
1 Points
3 Posts
Re: setting information
Jun 16, 2010 01:51 PM|kjoe|LINK
That worked. Thank you for your help
Contributor
2003 Points
685 Posts
Re: setting information
Jun 16, 2010 03:01 PM|Waqar_ali|LINK
Please mark as answer if it solved your problem.
Software Engineer
Please mark as answer if it help you.
Member
1 Points
3 Posts
Re: setting information
Jun 16, 2010 03:39 PM|kjoe|LINK
oh, sounds good. Done