By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

Data into textbox from MySql using C#

P: n/a

I am trying to retrieve data from a MySql database using, and it
works fine when putting the result into a
gridview (Code provided in the end of this mail).

However, I'd like to get the result into a textbox. Not the entire table,
but just one cell.
If for instance, the name "Bill" appears in the culumn named "FirstName", at
the row with PersonID = 5, I'd like this to go in a textbox using something
like "select FirstName where PersonID = 5"

Furthermore I would like to retrieve the date into variables so that I can
populate a table.

How can I do that!

Tahnks in advance.

This is the code:
<script runat="server">

private const string ConnStr = "Driver={MySQL ODBC 3.51 Driver};" +

"Server=localhost;Database=db1;uid=xxxx;pwd=yyyyy; option=3";

protected override void OnInit(EventArgs e)



using(OdbcConnection con = new OdbcConnection(ConnStr))

using(OdbcCommand cmd = new OdbcCommand("Select * from table1", con))



dgrAllNames.DataSource = cmd.ExecuteReader(

CommandBehavior.CloseConnection |






<html xmlns="">


<title>Displaying Records from MySQL 'Names' table</title>

<style type="text/css">

body { font: 100% Verdana; }




<center><p>All records in the 'Names' table:</p></center>

<asp:DataGrid ID="dgrAllNames" HorizontalAlign="Center"

CellPadding="3" Runat="server" />


Jul 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.