473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Data into textbox from MySql using ASP.net C#

Hello,

I am trying to retrieve data from a MySql database using ASP.net, 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)

{

base.OnInit(e);

using(OdbcConnection con = new OdbcConnection(ConnStr))

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

{

con.Open();

dgrAllNames.DataSource = cmd.ExecuteReader(

CommandBehavior.CloseConnection |

CommandBehavior.SingleResult);

dgrAllNames.DataBind();

}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

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

<style type="text/css">

body { font: 100% Verdana; }

</style>

</head>

<body>

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

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

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

</body>

</html>
Jul 7 '06 #1
0 2217

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
2
by: TN Bella | last post by:
PLEASE HELP!! I am so far behind....and it doesn't help that I am learning all this stuff. I am using .net framework 1.0 from WebMatrix. These parameters get me all confused...someone please help!...
2
by: Paul Evans | last post by:
Hi, Can anyone help me? I have two text boxes, one single-line and one multiline. I wish to save the text within the multiline textbox as a txt file, with a file name by the text in the...
3
by: eieiohh | last post by:
MySQL 3.23.49 PHP 4.3.8 Apache 2.0.51 Hi All! Newbie.. I had a CRM Open Source application installed and running. Windows Xp crashed. I was able to copy the contents of the entire hard...
1
by: giniapatel | last post by:
hello all, i m using forms 6i with oracle 10g. i have set Nls_lang =American_America.UTF8. Now my problem is when i type some data i marathi Using a font converter engine directly into the text...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
1
by: Alan | last post by:
Hi, I'm having a problem inserting a parameter into an SQL Select statement with <asp:ControlParameter>. This should be very simple, but for some reason it just isn't working: <%-- Get username...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
1
by: gubbachchi | last post by:
Hi, For my project I have a "add" button, upon clicking it, it will take the user to next page where there will be a text box and list of data displayed below it which is fetched from mysql...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.