473,388 Members | 1,234 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,388 software developers and data experts.

How can I display MySQL database table user info in c sharp

Hi all

I am a new c sharp programmer and I was looking at this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void button1_Click(object sender, EventArgs e)
  3. {
  4. string input = textBox3.Text;
  5. connectdatabase();
  6. string wow = "SELECT `CustomerName` FROM `CustomerInfo`";
  7. MySqlCommand wowcmd = new MySqlCommand(wow, connection);
  8. MySqlDataReader Reader;
  9. Reader = wowcmd.ExecuteReader();
  10. while (Reader.Read())
  11. {
  12. if (input == Convert.ToString(Reader))
  13. {
  14. textBox5.Text = Convert.ToString(Reader);
  15. }
  16. }
  17.  
  18.  
  19. }
  20. Post Reply
  21.  
And I was wondering if anyone could rewrite the code so that it display the MySQL table data for a specific user I already have a string called username and that stores the username entered on the login form. I want the code to use the username string to search for the name and display that users info.

My table contents are: username
First name
Last name
Position
Employee Id
Airline

If you do this it would be greatly appreciated
Aug 18 '12 #1

✓ answered by PsychoCoder

The only thing you need to do is to change your query. So change this

Expand|Select|Wrap|Line Numbers
  1. string wow = "SELECT `CustomerName` FROM `CustomerInfo`";
to this

Expand|Select|Wrap|Line Numbers
  1. string wow = "SELECT `CustomerName` FROM `CustomerInfo` where <Your Column> = <YourVariable>";
What you've done there is tell it to return everything for a certain user. Hope that helps.

Happy Coding!

7 20396
PsychoCoder
465 Expert Mod 256MB
Sorry but this isnt a code writing repository, so we're not going to rewrite your code
Aug 19 '12 #2
Can you at least tell me what too do
Aug 19 '12 #3
Grim
2
There is an example in MySQL Conenctor .Net, just look at it.
Aug 24 '12 #4
PsychoCoder
465 Expert Mod 256MB
The only thing you need to do is to change your query. So change this

Expand|Select|Wrap|Line Numbers
  1. string wow = "SELECT `CustomerName` FROM `CustomerInfo`";
to this

Expand|Select|Wrap|Line Numbers
  1. string wow = "SELECT `CustomerName` FROM `CustomerInfo` where <Your Column> = <YourVariable>";
What you've done there is tell it to return everything for a certain user. Hope that helps.

Happy Coding!
Aug 25 '12 #5
ariful alam
185 100+
Expand|Select|Wrap|Line Numbers
  1. select `first_name` + ' ' + `last_name` from `<table_name>` where username = <your variable name>
Aug 25 '12 #6
Thank you all for the help greatly appreciated guess I'm sticking with this for cause daniweb takes weeks to reply
Aug 25 '12 #7
PsychoCoder
465 Expert Mod 256MB
Glad we could help you with this.
Aug 26 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin Lucas-Smith | last post by:
Can anyone point me to a regular expression in PHP which could be used to check that a proposed (My)SQL database/table/column name is valid, i.e. shouldn't result in an SQL error when created? ...
1
by: Spidah | last post by:
Is there an easier way to get the number of items in a database table than selecting all the records in it and then running mysql_num_rows on the result? Hamilton www.laughland.biz
4
by: Hartmut Jaeger | last post by:
I want to delete a MySQL table without using functions of the OS, so that my php script can run on any webserver. Can I use a command like $sql = "DELETE FROM tablename"; or are there better...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
2
by: samui | last post by:
I'm trying to get a php page to show data from a MySQL database. But the problem that I have is I don't know where to start. I'm very new at PHP and I'm constantly told by others that it's very...
1
by: mahendravishwa | last post by:
Hi, I want to change DateTime format in MySQL Database Table in dd/MM/yyyy format. Its possible so please provide guidance. Thanks
4
by: baked | last post by:
Hi, I am using an html form to put a text into a Mysql database table. Using PHP V5 When I recover and display only one space between each word is seen irrespective of how many I add. The...
5
by: santusapi | last post by:
I want to know whether MySQL is secured? I want to know how to create user in MySQL and I don't want to share any of the table of one user to other. How would I do this?
2
by: KMEscherich | last post by:
Hi there, as I am totally new at this, can someone please give me detailed information on how to get Access table or query data to display onto a Dreamweaver page??? Thank you.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.